Is your feature request related to a problem? Please describe.
I'm unable to stop the track from auto-advancing to the next track. See Issue 917. I tried to stop the track from advancing with pause but it doesn't pause.
Describe the solution you'd like
Add a configuration option that lets you choose whether the track auto-advances to the next track or pauses after finishing. Right now the tracks all auto-advance if there is a next track.
Describe alternatives you've considered
Add the ability to pause in the event listener: Issue 917
Additional context
In our app, a user loads a playlist of tracks. They have a setting to choose whether the app should play the next track automatically or stop after each track. I would like to be able to update the Track Player config to reflect the user's choice of setting.
@Guichaguri is this an easy add on Android?
On iOS, SwiftAudio has a setting we can toggle.
However, looking briefly at Exoplayer, it seems ConcatenatingMediaSource doesn鈥檛 have an easy way to disable auto advancing. Which makes sense because seamless playback is the whole point.
Can we easily switch between media source types or something?
It's doable, but not very precisely with the ConcatenatingMediaSource. Pausing in playback-track-changed should work on Android though.
I think I had tried that for some other reason and you end up getting blips of the next track 馃槥
I guess we should determine if this is necessary. Devs can always just not use the RNTP queue and do a single track at a time.
This can possibly cause issues when trying to change to the next track in the background though.
Guess what?
It just became possible to make this work in ExoPlayer.
https://github.com/google/ExoPlayer/issues/5660#issuecomment-619067418
Nice!
So what approach do you think makes sense for exposing this in the TrackPlayer API?
Also, would we need a new playback event to know when the track is complete?
I think we should still advance into the next track as expected, but set it to the paused state. playback-track-changed would still be triggered.
It would make sense to add a setter/getter for that, as setOptions is only related to metadata stuff and setupPlayer, which is related to the player, can not be updated dynamically.
hmm, I'll have to check, but I don't think this would match the default behavior on iOS by just disabling the auto play feature of SwiftAudio. On iOS I don't think it would go to the next track. But that may be easy to tweak.
ExoPlayer doesn't advance either, so I don't know whether we should add a new event just for that or advance the track.
You can probably listen to playback-state, but that's not very intuitive either.
Maybe this would be related to other requests I have noticed regarding how to know when a track actually finished? A new event, such as playback-track-complete that only fires if it played to the end could maybe address those requests, and this one?
Yeah, that should work
Maybe this would be related to other requests I have noticed regarding how to know when a track actually finished? A new event, such as
playback-track-completethat only fires if it played to the end could maybe address those requests, and this one?
guys any update related to playback-track-complete
This playback-track-complete value would be to mimic the behavior of the didJustFinish boolean in expo-av. Perhaps you can even call it similarly.
It would be important to add it since people moving here from expo-av (e.g. after ejecting an expo app - me for example 馃槈 ) are used to this functionality.
I also ejected from expo and was using the didJustFinish on expo-av which was helpful for our use. Now that logic is in "playback-track-changed" but it makes more sense to do on a "playback-track-complete".聽
The 2 main things we would want on a track's finish:
Hey guys - so are you saying there is no way to stop this from auto-advancing on iOS? Like, if I have more than one track loaded it's not possible for me to prevent it from playing all the tracks in the queue?
Also, plus one for an 'onEnded' event. I kind of can't believe this library doesn't have this
any updates on auto-play = false - behaviour?
Most helpful comment
Maybe this would be related to other requests I have noticed regarding how to know when a track actually finished? A new event, such as
playback-track-completethat only fires if it played to the end could maybe address those requests, and this one?