mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-15 00:42:54 +01:00
playback: keep detached fallback out of published position
This commit is contained in:
@@ -1863,6 +1863,7 @@ class PlaybackController(
|
|||||||
|
|
||||||
private fun refresh(position: Long? = currentQueuePosition()) {
|
private fun refresh(position: Long? = currentQueuePosition()) {
|
||||||
val player = player ?: return
|
val player = player ?: return
|
||||||
|
val publishedPosition = if (detachedWindow && currentPosition() == null) lastPosition ?: detachedPosition else position
|
||||||
updateBuffering()
|
updateBuffering()
|
||||||
val durationMs =
|
val durationMs =
|
||||||
player.durationMs.takeIf { it > 0 }
|
player.durationMs.takeIf { it > 0 }
|
||||||
@@ -1871,8 +1872,8 @@ class PlaybackController(
|
|||||||
_state.value =
|
_state.value =
|
||||||
PlaybackState(
|
PlaybackState(
|
||||||
item = player.currentItem,
|
item = player.currentItem,
|
||||||
context = contextAt(position),
|
context = contextAt(publishedPosition),
|
||||||
position = position,
|
position = publishedPosition,
|
||||||
isBuffering = showBuffering,
|
isBuffering = showBuffering,
|
||||||
isPlaying = player.playWhenReady && !player.isIdle && !player.isEnded,
|
isPlaying = player.playWhenReady && !player.isIdle && !player.isEnded,
|
||||||
durationMs = durationMs,
|
durationMs = durationMs,
|
||||||
|
|||||||
@@ -4286,6 +4286,7 @@ class PlaybackControllerTest {
|
|||||||
runBlocking { queues.resetChangedOrigins(setOf(QueueOrigin(QueueKind.Playlist, 1, "p1")), point) }
|
runBlocking { queues.resetChangedOrigins(setOf(QueueOrigin(QueueKind.Playlist, 1, "p1")), point) }
|
||||||
await { handle.items.map { it.id } == listOf("s2") && controller.state.value.position == null }
|
await { handle.items.map { it.id } == listOf("s2") && controller.state.value.position == null }
|
||||||
controller.cycleRepeat()
|
controller.cycleRepeat()
|
||||||
|
assertNull(controller.state.value.position)
|
||||||
assertEquals(RepeatMode.All, controller.state.value.repeat)
|
assertEquals(RepeatMode.All, controller.state.value.repeat)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user