From 045247041d9efd045c41f022191101a2d52682c8 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Sun, 23 Nov 2025 17:21:12 +0800 Subject: [PATCH] fix: prevent unnecessary video seeking if current time is close to initial playback time. --- components/player/hooks/desktop/usePlaybackControls.ts | 5 +++-- components/player/hooks/mobile/useMobilePlaybackControls.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/player/hooks/desktop/usePlaybackControls.ts b/components/player/hooks/desktop/usePlaybackControls.ts index 0cc53fa..82762fb 100644 --- a/components/player/hooks/desktop/usePlaybackControls.ts +++ b/components/player/hooks/desktop/usePlaybackControls.ts @@ -72,8 +72,9 @@ export function usePlaybackControls({ useEffect(() => { if (initialTime > 0 && videoRef.current) { // Only seek if we haven't progressed far (e.g. still near start) - // This prevents jumping if the user has already started watching - if (videoRef.current.currentTime < 2) { + // AND if the target time is significantly different from current time (> 0.5s) + // This prevents jumping if the user has already started watching and initialTime updates + if (videoRef.current.currentTime < 2 && Math.abs(videoRef.current.currentTime - initialTime) > 0.5) { videoRef.current.currentTime = initialTime; } } diff --git a/components/player/hooks/mobile/useMobilePlaybackControls.ts b/components/player/hooks/mobile/useMobilePlaybackControls.ts index 0c4d89c..49e8fcd 100644 --- a/components/player/hooks/mobile/useMobilePlaybackControls.ts +++ b/components/player/hooks/mobile/useMobilePlaybackControls.ts @@ -87,8 +87,9 @@ export function useMobilePlaybackControls({ useEffect(() => { if (initialTime > 0 && videoRef.current) { // Only seek if we haven't progressed far (e.g. still near start) - // This prevents jumping if the user has already started watching - if (videoRef.current.currentTime < 2) { + // AND if the target time is significantly different from current time (> 0.5s) + // This prevents jumping if the user has already started watching and initialTime updates + if (videoRef.current.currentTime < 2 && Math.abs(videoRef.current.currentTime - initialTime) > 0.5) { videoRef.current.currentTime = initialTime; } }