Skip to content

Commit

Permalink
Fix QueueService.next not respecting usePlaybackOrder and useRepeatMo…
Browse files Browse the repository at this point in the history
…de properly
  • Loading branch information
nielsvanvelzen committed Dec 21, 2024
1 parent 5547bbc commit 25e79e9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions playback/core/src/main/kotlin/queue/QueueService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ class QueueService internal constructor() : PlayerService(), Queue {

override suspend fun next(usePlaybackOrder: Boolean, useRepeatMode: Boolean): QueueEntry? {
val index = getNextIndices(1, usePlaybackOrder, useRepeatMode).firstOrNull() ?: return null
if (usePlaybackOrder) {
// Automatically set repeat mode back to none when using the ONCE option
if (state.repeatMode.value == RepeatMode.REPEAT_ENTRY_ONCE && index == this._entryIndex.value) {
state.setRepeatMode(RepeatMode.NONE)
} else if (state.repeatMode.value == RepeatMode.NONE) {
orderIndexProvider.useNextIndex()
}

val provider = if (usePlaybackOrder) orderIndexProvider else defaultOrderIndexProvider
val repeatMode = if (useRepeatMode) state.repeatMode.value else RepeatMode.NONE

// Automatically set repeat mode back to none when using the ONCE option
if (repeatMode == RepeatMode.REPEAT_ENTRY_ONCE && index == this._entryIndex.value) {
state.setRepeatMode(RepeatMode.NONE)
} else if (repeatMode == RepeatMode.NONE) {
provider.useNextIndex()
}

return setIndex(index, true)
Expand Down

0 comments on commit 25e79e9

Please sign in to comment.