Skip to content

Commit

Permalink
Fix queue not advancing
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Sep 28, 2024
1 parent b219f46 commit 56eb001
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions playback/core/src/main/kotlin/queue/QueueService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56eb001

Please sign in to comment.