Skip to content

Commit 5d3fb4c

Browse files
committed
fix(player): publish the position on seeks while paused so every seek bar follows it
1 parent 2cb77b8 commit 5d3fb4c

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎data/src/androidMain/kotlin/com/maxrave/data/mediaservice/MediaServiceHandlerImpl.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,6 +2765,10 @@ internal class MediaServiceHandlerImpl(
27652765
// refresh the RPC timestamps so Discord's progress bar follows the new position.
27662766
if (player.isPlaying) {
27672767
nowPlayingState.value.songEntity?.let { updateDiscordRpc(it) }
2768+
} else {
2769+
// Paused, the progress ticker is stopped, so nothing else tells the UI the position
2770+
// moved: every seek bar, clock and lyric line would wait for play to catch up (#2480).
2771+
_simpleMediaState.value = SimpleMediaState.Progress(positionMs)
27682772
}
27692773
}
27702774

‎data/src/jvmMain/kotlin/com/maxrave/data/mediaservice/JvmMediaPlayerHandlerImpl.kt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,6 +2794,15 @@ class JvmMediaPlayerHandlerImpl(
27942794
updateMacOSPlaybackState(isPlaying)
27952795
}
27962796

2797+
override fun onSeeked(positionMs: Long) {
2798+
// Paused, the progress ticker is stopped, so nothing else tells the UI the position moved:
2799+
// every seek bar, clock and lyric line would wait for play to catch up (#2480). Unlike the
2800+
// Android twin there is no Discord refresh here: each seek branch already does it.
2801+
if (!player.isPlaying) {
2802+
_simpleMediaState.value = SimpleMediaState.Progress(positionMs)
2803+
}
2804+
}
2805+
27972806
override fun onMediaItemTransition(
27982807
mediaItem: GenericMediaItem?,
27992808
reason: Int,

‎media/media-jvm/src/main/java/com/simpmusic/media_jvm/mpv/MpvPlayerAdapter.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ class MpvPlayerAdapter(
414414
try {
415415
player.seekTo(positionMs)
416416
Logger.d(TAG, "Seeked to position: $positionMs")
417+
// Same contract as the Android adapter: every seek is reported, whoever asked
418+
// for it (seek bar, lyric tap, ±5 s, Control Center, SponsorBlock).
419+
notifyListeners { onSeeked(positionMs) }
417420
} catch (e: Exception) {
418421
Logger.e(TAG, "Seek exception: ${e.message}", e)
419422
}

0 commit comments

Comments
 (0)