From 4aa67dc6f3b6986d9109fa6e2a56859d2c8b069d Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Sat, 21 Dec 2024 19:47:41 +0100 Subject: [PATCH 1/2] Fix repeat mode not working --- playback/core/src/main/kotlin/PlayerState.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playback/core/src/main/kotlin/PlayerState.kt b/playback/core/src/main/kotlin/PlayerState.kt index 17e160b771..cd340c1ab4 100644 --- a/playback/core/src/main/kotlin/PlayerState.kt +++ b/playback/core/src/main/kotlin/PlayerState.kt @@ -88,7 +88,13 @@ class MutablePlayerState( _videoSize.value = VideoSize(width, height) } - override fun onMediaStreamEnd(mediaStream: PlayableMediaStream) = Unit + override fun onMediaStreamEnd(mediaStream: PlayableMediaStream) { + // Make sure to start stream again if repeat mode is turned on + // Note: the QueueService is responsible for changing REPEAT_ENTRY_ONCE to NONE + if (_repeatMode.value != RepeatMode.NONE) { + backendService.backend?.play() + } + } }) volume = options.playerVolumeState From f0b796f3f7e1fc4f1d3fec48701435c12236a694 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Sat, 21 Dec 2024 19:47:58 +0100 Subject: [PATCH 2/2] Use private entry index in QueueService --- playback/core/src/main/kotlin/queue/QueueService.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playback/core/src/main/kotlin/queue/QueueService.kt b/playback/core/src/main/kotlin/queue/QueueService.kt index 192bc24f6a..e6b9e067cd 100644 --- a/playback/core/src/main/kotlin/queue/QueueService.kt +++ b/playback/core/src/main/kotlin/queue/QueueService.kt @@ -113,14 +113,14 @@ class QueueService internal constructor() : PlayerService(), Queue { val repeatMode = if (useRepeatMode) state.repeatMode.value else RepeatMode.NONE return when (repeatMode) { - RepeatMode.NONE -> provider.provideIndices(amount, estimatedSize, currentQueueIndicesPlayed, entryIndex.value) + RepeatMode.NONE -> provider.provideIndices(amount, estimatedSize, currentQueueIndicesPlayed, _entryIndex.value) RepeatMode.REPEAT_ENTRY_ONCE -> buildList(amount) { - add(entryIndex.value) - addAll(provider.provideIndices(amount - 1, estimatedSize, currentQueueIndicesPlayed, entryIndex.value)) + add(_entryIndex.value) + addAll(provider.provideIndices(amount - 1, estimatedSize, currentQueueIndicesPlayed, _entryIndex.value)) }.take(amount) - RepeatMode.REPEAT_ENTRY_INFINITE -> List(amount) { entryIndex.value } + RepeatMode.REPEAT_ENTRY_INFINITE -> List(amount) { _entryIndex.value } } }