playback: fix playNext crash on last song of queue
Fixes OxygenCobalt/Auxio#735. ExoPlayer method for fetching next media item returns C.INDEX_UNSET (-1) when used on the last song of a queue, which is not a valid index for ExoPlayer.addMediaItems(). New code just adds songs to the end of the queue if there isn't a next song.
This commit is contained in:
parent
261edf6c65
commit
e0352a105a
1 changed files with 8 additions and 1 deletions
|
@ -362,7 +362,14 @@ constructor(
|
|||
}
|
||||
|
||||
override fun playNext(songs: List<Song>, ack: StateAck.PlayNext) {
|
||||
player.addMediaItems(player.nextMediaItemIndex, songs.map { it.toMediaItem() })
|
||||
val nextIndex = player.nextMediaItemIndex
|
||||
|
||||
if (nextIndex == C.INDEX_UNSET) {
|
||||
player.addMediaItems(songs.map { it.toMediaItem() })
|
||||
} else {
|
||||
player.addMediaItems(nextIndex, songs.map { it.toMediaItem() })
|
||||
}
|
||||
|
||||
playbackManager.ack(this, ack)
|
||||
deferSave()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue