From f2315e91cb905be6570642ba04a0f48b10f37358 Mon Sep 17 00:00:00 2001 From: Dmitri Date: Mon, 6 Apr 2026 17:08:01 +0400 Subject: [PATCH] new fixes for playback --- frontend/src/hooks/useReversePlayback.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/hooks/useReversePlayback.ts b/frontend/src/hooks/useReversePlayback.ts index f9b4aef..5da8249 100644 --- a/frontend/src/hooks/useReversePlayback.ts +++ b/frontend/src/hooks/useReversePlayback.ts @@ -101,8 +101,12 @@ export function useReversePlayback( cleanupFnsRef.current.forEach((fn) => fn()); cleanupFnsRef.current = []; const video = options.videoRef.current; - if (video && video.playbackRate !== 1) { - video.playbackRate = 1; + if (video) { + if (video.playbackRate !== 1) { + video.playbackRate = 1; + } + // Ensure video visibility is restored + video.style.opacity = '1'; } }, [options.videoRef]); @@ -202,6 +206,8 @@ export function useReversePlayback( } const beginFrameStepping = () => { + // Restore visibility now that we're at the correct frame + video.style.opacity = '1'; video.pause(); let lastFrameTime = performance.now(); let stepCount = 0; @@ -367,10 +373,12 @@ export function useReversePlayback( () => video.removeEventListener('ended', onEnded), ); - // Start playback to trigger buffering, but from near the end - // to avoid showing frame 0 (which would flash the target page) + // Start playback to trigger buffering + // Hide video via direct DOM manipulation to avoid flash + // (React state update is async, so isBuffering won't hide it in time) video.muted = true; - video.currentTime = actualDuration - 0.1; + video.style.opacity = '0'; + video.currentTime = 0; video.play().catch(() => undefined); // Fallback timeout