From 25e79e939ec296d9f56ca80c7f66ee11390f9285 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Fri, 20 Dec 2024 22:27:08 +0100 Subject: [PATCH] Fix QueueService.next not respecting usePlaybackOrder and useRepeatMode properly --- .../core/src/main/kotlin/queue/QueueService.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/playback/core/src/main/kotlin/queue/QueueService.kt b/playback/core/src/main/kotlin/queue/QueueService.kt index 7961cdc419..0ad1867206 100644 --- a/playback/core/src/main/kotlin/queue/QueueService.kt +++ b/playback/core/src/main/kotlin/queue/QueueService.kt @@ -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)