From 3ef42ce7ec632605c3e953a2b1d958f33aad9e9f Mon Sep 17 00:00:00 2001 From: "Elie G." Date: Sun, 8 Mar 2026 07:14:01 +0200 Subject: [PATCH] Fix currentTime and sliderPos not reaching end of media The last decoded frame's PTS is always slightly before the total duration (duration = last_frame_pts + frame_duration). Snap currentTime and progress to their final values when EOF is reached so the UI correctly shows 100% completion. Fixes #138 --- .../composemediaplayer/windows/WindowsVideoPlayerState.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/windows/WindowsVideoPlayerState.kt b/mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/windows/WindowsVideoPlayerState.kt index 89f47b6..7907b9f 100644 --- a/mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/windows/WindowsVideoPlayerState.kt +++ b/mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/windows/WindowsVideoPlayerState.kt @@ -703,6 +703,13 @@ class WindowsVideoPlayerState : VideoPlayerState { setError("Error during SeekMedia for loop: ${e.message}") } } else { + // The last decoded frame's timestamp is always slightly before the + // total duration (duration = last_frame_pts + frame_duration), so + // snap currentTime/progress to the end when playback completes. + if (_duration > 0.0) { + _currentTime = _duration + _progress = 1f + } pause() break }