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

Unset playing item once the playback queue ends #4221

Merged
Merged
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
7 changes: 4 additions & 3 deletions playback/core/src/main/kotlin/queue/QueueService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class QueueService internal constructor() : PlayerService(), Queue {
override fun onVideoSizeChange(width: Int, height: Int) = Unit
override fun onMediaStreamEnd(mediaStream: PlayableMediaStream) {
coroutineScope.launch {
next(usePlaybackOrder = true, useRepeatMode = true)
val nextItem = next(usePlaybackOrder = true, useRepeatMode = true)
if (nextItem == null && _entryIndex.value != Queue.INDEX_NONE) setIndex(Queue.INDEX_NONE, true)
}
}
})
Expand Down Expand Up @@ -91,7 +92,7 @@ class QueueService internal constructor() : PlayerService(), Queue {
}

// Return item or null if not found
return if (index < fetchedItems.size) fetchedItems[index]
return if (index >= 0 && index < fetchedItems.size) fetchedItems[index]
else null
}

Expand Down Expand Up @@ -144,7 +145,7 @@ class QueueService internal constructor() : PlayerService(), Queue {
}

override suspend fun setIndex(index: Int, saveHistory: Boolean): QueueEntry? {
if (index < 0) return null
if (index < 0 && index != Queue.INDEX_NONE) return null

// Save previous index
if (saveHistory && _entryIndex.value != Queue.INDEX_NONE) {
Expand Down
Loading