mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-22 17:41:39 +00:00
fix(player): persist previous item progress before updating position snapshot
Reorder the position/duration snapshot in ProgressManager.bind() so stopSession() reads the previous item's last-known position instead of the next item's seek target. Fixes the offline Room database being written with 0% progress on item transitions.
This commit is contained in:
@@ -43,8 +43,6 @@ class ProgressManager @Inject constructor(
|
||||
combine(playbackState, progress, metadata) { state, prog, meta ->
|
||||
Triple(state, prog, meta)
|
||||
}.collect { (state, prog, meta) ->
|
||||
lastPositionMs = prog.positionMs
|
||||
lastDurationMs = prog.durationMs
|
||||
isPaused = !state.isPlaying
|
||||
val mediaId = meta.mediaId?.let { runCatching { UUID.fromString(it) }.getOrNull() }
|
||||
val nextPlaybackReportContext = meta.playbackReportContext
|
||||
@@ -53,6 +51,9 @@ class ProgressManager @Inject constructor(
|
||||
stopSession()
|
||||
}
|
||||
|
||||
lastPositionMs = prog.positionMs
|
||||
lastDurationMs = prog.durationMs
|
||||
|
||||
if (activeItemId == null && mediaId != null && !state.isEnded) {
|
||||
startSession(mediaId, prog.positionMs, nextPlaybackReportContext)
|
||||
} else if (activeItemId == mediaId) {
|
||||
|
||||
Reference in New Issue
Block a user