From 7bb79e1a8c704dac3d06563a37777058400e2164 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 5 Mar 2024 08:16:43 -0700 Subject: [PATCH] Fix not loading preview when changing hours --- .../components/player/DynamicVideoPlayer.tsx | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/web/src/components/player/DynamicVideoPlayer.tsx b/web/src/components/player/DynamicVideoPlayer.tsx index 3447d4337..37a4d509a 100644 --- a/web/src/components/player/DynamicVideoPlayer.tsx +++ b/web/src/components/player/DynamicVideoPlayer.tsx @@ -85,6 +85,16 @@ export default function DynamicVideoPlayer({ ); }, [camera, config, previewOnly]); + useEffect(() => { + if (!controller) { + return; + } + + if (onControllerReady) { + onControllerReady(controller); + } + }, [controller, onControllerReady]); + const [hasRecordingAtTime, setHasRecordingAtTime] = useState(true); // keyboard control @@ -215,6 +225,10 @@ export default function DynamicVideoPlayer({ ); setCurrentPreview(preview); + if (preview && previewRef.current) { + previewRef.current.load(); + } + controller.newPlayback({ recordings: recordings ?? [], playbackUri, @@ -283,27 +297,20 @@ export default function DynamicVideoPlayer({ )} {onClick && !hasRecordingAtTime && ( -
+
)}
);