new fixes for playback

This commit is contained in:
Dmitri 2026-04-06 17:08:01 +04:00
parent 4bb9a8bfd3
commit f2315e91cb

View File

@ -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