Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repeat mode not working #4330

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion playback/core/src/main/kotlin/PlayerState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions playback/core/src/main/kotlin/queue/QueueService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
Loading