From 3f54f52dd6d4f672b01f954a3052ae4432625c77 Mon Sep 17 00:00:00 2001 From: "federico.gambassi@tomatoai.it" Date: Fri, 30 Oct 2026 18:43:24 +0100 Subject: [PATCH] fix(macos): seek HLS streams exactly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The HLS branch of seekTo used a fixed ±1 s tolerance, so AVPlayer landed on the nearest keyframe: with a 2 s GOP the position ended up to a second away from the requested time, and a scrubber jumped back after every drag. Seek with zero tolerance before and after. Co-Authored-By: Claude Opus 5.5 --- .../src/jvmMain/native/macos/NativeVideoPlayer.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mediaplayer/src/jvmMain/native/macos/NativeVideoPlayer.swift b/mediaplayer/src/jvmMain/native/macos/NativeVideoPlayer.swift index 36d1318a..775caa93 100644 --- a/mediaplayer/src/jvmMain/native/macos/NativeVideoPlayer.swift +++ b/mediaplayer/src/jvmMain/native/macos/NativeVideoPlayer.swift @@ -1311,10 +1311,10 @@ class MacVideoPlayer { guard let player = player else { return } let newTime = CMTime(seconds: time, preferredTimescale: 600) - // For HLS, use tolerance for more efficient seeking + // HLS seeks are exact: a tolerance lets AVPlayer land on the nearest keyframe, up to a second + // away from where the user dropped the slider if isHLSStream { - let tolerance = CMTime(seconds: 1.0, preferredTimescale: 600) - player.seek(to: newTime, toleranceBefore: tolerance, toleranceAfter: tolerance) + player.seek(to: newTime, toleranceBefore: .zero, toleranceAfter: .zero) } else { player.seek(to: newTime)