mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-14 16:23:43 +08:00
fix: prevent unnecessary video seeking if current time is close to initial playback time.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user