From 5e8bb99e9649d7efc2cf0c24f88d587749b804ae Mon Sep 17 00:00:00 2001 From: Siddharth Date: Fri, 13 Mar 2026 23:00:11 -0700 Subject: [PATCH] fix playback callback to not be in pixi setup dependency --- src/components/video-editor/VideoPlayback.tsx | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx index c4598ac..98a4c23 100644 --- a/src/components/video-editor/VideoPlayback.tsx +++ b/src/components/video-editor/VideoPlayback.tsx @@ -149,6 +149,8 @@ const VideoPlayback = forwardRef( const trimRegionsRef = useRef([]); const speedRegionsRef = useRef([]); const motionBlurEnabledRef = useRef(motionBlurEnabled); + const onTimeUpdateRef = useRef(onTimeUpdate); + const onPlayStateChangeRef = useRef(onPlayStateChange); const videoReadyRafRef = useRef(null); const clampFocusToStage = useCallback((focus: ZoomFocus, depth: ZoomDepth) => { @@ -379,6 +381,14 @@ const VideoPlayback = forwardRef( motionBlurEnabledRef.current = motionBlurEnabled; }, [motionBlurEnabled]); + useEffect(() => { + onTimeUpdateRef.current = onTimeUpdate; + }, [onTimeUpdate]); + + useEffect(() => { + onPlayStateChangeRef.current = onPlayStateChange; + }, [onPlayStateChange]); + useEffect(() => { if (!pixiReady || !videoReady) return; @@ -545,6 +555,11 @@ const VideoPlayback = forwardRef( }, []); useEffect(() => { + if (!videoPath) { + setVideoReady(false); + return; + } + const video = videoRef.current; if (!video) return; video.pause(); @@ -556,7 +571,7 @@ const VideoPlayback = forwardRef( cancelAnimationFrame(videoReadyRafRef.current); videoReadyRafRef.current = null; } - }, []); + }, [videoPath]); useEffect(() => { if (!pixiReady || !videoReady) return; @@ -599,7 +614,7 @@ const VideoPlayback = forwardRef( videoContainer.filters = [blurFilter]; blurFilterRef.current = blurFilter; - layoutVideoContent(); + layoutVideoContentRef.current?.(); video.pause(); const { handlePlay, handlePause, handleSeeked, handleSeeking } = createVideoEventHandlers({ @@ -609,8 +624,8 @@ const VideoPlayback = forwardRef( allowPlaybackRef, currentTimeRef, timeUpdateAnimationRef, - onPlayStateChange, - onTimeUpdate, + onPlayStateChange: (playing) => onPlayStateChangeRef.current(playing), + onTimeUpdate: (time) => onTimeUpdateRef.current(time), trimRegionsRef, speedRegionsRef, }); @@ -651,7 +666,7 @@ const VideoPlayback = forwardRef( videoSpriteRef.current = null; }; - }, [pixiReady, videoReady, onTimeUpdate, onPlayStateChange, layoutVideoContent]); + }, [pixiReady, videoReady]); useEffect(() => { if (!pixiReady || !videoReady) return;