diff --git a/web/src/components/player/PreviewPlayer.tsx b/web/src/components/player/PreviewPlayer.tsx index a5f3f771c..9275101b8 100644 --- a/web/src/components/player/PreviewPlayer.tsx +++ b/web/src/components/player/PreviewPlayer.tsx @@ -197,6 +197,7 @@ function PreviewVideoPlayer({ const canvasRef = useRef(null); const [videoSize, setVideoSize] = useState([0, 0]); + const [changeoverTimeout, setChangeoverTimeout] = useState(); const changeSource = useCallback( (newPreview: Preview | undefined, video: HTMLVideoElement | null) => { @@ -220,6 +221,15 @@ function PreviewVideoPlayer({ } setCurrentPreview(newPreview); + const timeout = setTimeout(() => { + if (timeout) { + clearTimeout(timeout); + setChangeoverTimeout(undefined); + } + + previewRef.current?.load(); + }, 1000); + setChangeoverTimeout(timeout); // we only want this to change when current preview changes // eslint-disable-next-line react-hooks/exhaustive-deps @@ -243,6 +253,7 @@ function PreviewVideoPlayer({ ); if (preview != currentPreview) { + controller.newPreviewLoaded = false; changeSource(preview, previewRef.current); } @@ -267,7 +278,14 @@ function PreviewVideoPlayer({ previewRef.current?.load()} + onLoad={() => { + if (changeoverTimeout) { + clearTimeout(changeoverTimeout); + setChangeoverTimeout(undefined); + } + + previewRef.current?.load(); + }} />