playback: fix playNext wraparound with Repeat All
ExoPlayer method for fetching next media item respects Repeat All, which on the last song of a queue causes playNext to wrap around and insert the songs at the start of the queue. New code fetches next song as if repeat were turned off, so the songs will always be added to the end of the queue.
This commit is contained in:
@@ -377,7 +377,17 @@ class PlaybackService :
|
||||
}
|
||||
|
||||
override fun playNext(songs: List<Song>, ack: StateAck.PlayNext) {
|
||||
val nextIndex = player.nextMediaItemIndex
|
||||
val currTimeline = player.currentTimeline
|
||||
val nextIndex =
|
||||
if (currTimeline.isEmpty) {
|
||||
C.INDEX_UNSET
|
||||
} else {
|
||||
currTimeline.getNextWindowIndex(
|
||||
player.currentMediaItemIndex,
|
||||
Player.REPEAT_MODE_OFF,
|
||||
player.shuffleModeEnabled
|
||||
)
|
||||
}
|
||||
|
||||
if (nextIndex == C.INDEX_UNSET) {
|
||||
player.addMediaItems(songs.map { it.toMediaItem() })
|
||||
|
||||
Reference in New Issue
Block a user