diff --git a/components/player/hooks/desktop/usePlaybackControls.ts b/components/player/hooks/desktop/usePlaybackControls.ts index a182517..9e90777 100644 --- a/components/player/hooks/desktop/usePlaybackControls.ts +++ b/components/player/hooks/desktop/usePlaybackControls.ts @@ -64,9 +64,12 @@ export function usePlaybackControls({ setIsLoading(false); // Fix for stuck at 00:00:00: - // If initialTime is 0, we seek to a tiny offset to help the browser/HLS buffer start. - const startPosition = initialTime > 0 ? initialTime : 0.1; - videoRef.current.currentTime = startPosition; + // Only seek if we are at the very start (to avoid overwriting a previous seek) + if (videoRef.current.currentTime < 0.5) { + // If initialTime is 0, we seek to a tiny offset to help the browser/HLS buffer start. + const startPosition = initialTime > 0 ? initialTime : 0.1; + videoRef.current.currentTime = startPosition; + } videoRef.current.play().catch((err: Error) => { console.warn('Autoplay was prevented:', err); diff --git a/components/player/hooks/mobile/useMobilePlaybackControls.ts b/components/player/hooks/mobile/useMobilePlaybackControls.ts index fa83734..9682f89 100644 --- a/components/player/hooks/mobile/useMobilePlaybackControls.ts +++ b/components/player/hooks/mobile/useMobilePlaybackControls.ts @@ -79,9 +79,12 @@ export function useMobilePlaybackControls({ setIsLoading(false); // Fix for stuck at 00:00:00: - // If initialTime is 0, we seek to a tiny offset to help the browser/HLS buffer start. - const startPosition = initialTime > 0 ? initialTime : 0.1; - videoRef.current.currentTime = startPosition; + // Only seek if we are at the very start (to avoid overwriting a previous seek) + if (videoRef.current.currentTime < 0.5) { + // If initialTime is 0, we seek to a tiny offset to help the browser/HLS buffer start. + const startPosition = initialTime > 0 ? initialTime : 0.1; + videoRef.current.currentTime = startPosition; + } videoRef.current.play().catch((err: Error) => { console.warn('Autoplay was prevented:', err); diff --git a/components/player/hooks/useHLSPreloader.ts b/components/player/hooks/useHLSPreloader.ts index feeeaf3..c698e18 100644 --- a/components/player/hooks/useHLSPreloader.ts +++ b/components/player/hooks/useHLSPreloader.ts @@ -61,6 +61,10 @@ export function useHLSPreloader({ src, currentTime }: UseHLSPreloaderProps) { } } + // Offset start index by 3 segments to avoid competing with browser playback + // The browser needs the immediate segments NOW; we preload the future. + startIndex = Math.min(startIndex + 3, segmentsRef.current.length - 1); + if (startIndex >= segmentsRef.current.length) return; // Check if this is sequential playback or a seek