From 56eb00197c37dbb75cb0eea749eb3fe184d24d0a Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Sat, 28 Sep 2024 16:47:28 +0200 Subject: [PATCH] Fix queue not advancing --- .../core/src/main/kotlin/queue/QueueService.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/playback/core/src/main/kotlin/queue/QueueService.kt b/playback/core/src/main/kotlin/queue/QueueService.kt index aae04da267..1c4a3e7a77 100644 --- a/playback/core/src/main/kotlin/queue/QueueService.kt +++ b/playback/core/src/main/kotlin/queue/QueueService.kt @@ -7,6 +7,9 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import org.jellyfin.playback.core.PlaybackManager +import org.jellyfin.playback.core.backend.PlayerBackendEventListener +import org.jellyfin.playback.core.mediastream.PlayableMediaStream +import org.jellyfin.playback.core.model.PlayState import org.jellyfin.playback.core.model.PlaybackOrder import org.jellyfin.playback.core.model.RepeatMode import org.jellyfin.playback.core.plugin.PlayerService @@ -44,6 +47,17 @@ class QueueService internal constructor() : PlayerService(), Queue { PlaybackOrder.SHUFFLE -> ShuffleOrderIndexProvider() } }.launchIn(coroutineScope) + + // Automatically advance when current stream ends + manager.backendService.addListener(object : PlayerBackendEventListener { + override fun onPlayStateChange(state: PlayState) = Unit + override fun onVideoSizeChange(width: Int, height: Int) = Unit + override fun onMediaStreamEnd(mediaStream: PlayableMediaStream) { + coroutineScope.launch { + next(usePlaybackOrder = true, useRepeatMode = true) + } + } + }) } // Entry management