ionic-audio icon indicating copy to clipboard operation
ionic-audio copied to clipboard

Playlist - Play audio files one after the other automatically

Open devshisiyani opened this issue 8 years ago • 3 comments

Is there a way to play tracks in a playlist one by one until you get to the end of your play list. Also is there a way to highlight the track or show play icon next to the track while the track is been played in your playlist. I have used your ionic 2 audio example which work great. I would like to extend your audio example further. Some code snippets would be useful to help me get started. Happy to base it on your audio example

thanks

devshisiyani avatar Jan 12 '17 21:01 devshisiyani

You will need to build your own implementation to do this.

In fact that is what I have done. I took audio-track-component, turned it into a service, and inject it into my playlist. Then I call its methods directly, instead of having the audio-track-play be a mediator. So that means I had to wire up my own button events and "selected track" handling too.

I don't think it makes sense to add any of this on to ionic-audio but I will get it up on github eventually.

codinronan avatar Mar 29 '17 08:03 codinronan

I guess for the first part of the question about playlist playback you could implement onFinish?

i.e. <audio-track #audio [track]="currentTrack" (onFinish)="onTrackFinished($event)">

So you could do:

// next track switch pseudo code example
onTrackFinished(track: any) {
  let nextTrackIndex = this.currentTrackIndex+1; // get next track index
  this.audioProvider.pause(); // pause current track
  this.currentTrack = this.audioProvider.tracks[nextTrackIndex];
  this.currentTrackIndex = nextTrackIndex;
  this.audioProvider.play(nextTrackIndex); // play next track
}

So when the track ends, you switch to the next and start playback? Just a thought.

tbergeron avatar May 30 '17 15:05 tbergeron

hi @codinronan Can you explain a bit more? And put the code you wrote here Thankful

sajad93 avatar Jun 04 '18 22:06 sajad93