diff --git a/src/renderer/src/hooks/useVideo.ts b/src/renderer/src/hooks/useVideo.ts index a1a8dfc2..d245a005 100644 --- a/src/renderer/src/hooks/useVideo.ts +++ b/src/renderer/src/hooks/useVideo.ts @@ -66,10 +66,6 @@ export default ({ filePath }: { filePath: string | undefined }) => { setCompatPlayerEventId((id) => id + 1); // To make sure that we can seek even to the same commanded time that we are already add (e.g. loop current segment) }, [smoothSeek]); - const seekRel = useCallback((val: number) => { - seekAbs(videoRef.current!.currentTime + val); - }, [seekAbs, videoRef]); - const commandedTimeRef = useRef(commandedTime); useEffect(() => { commandedTimeRef.current = commandedTime; @@ -80,6 +76,10 @@ export default ({ filePath }: { filePath: string | undefined }) => { // The reason why we also have a getter is because it can be used when we need to get the time, but don't want to re-render for every time update (which can be heavy!) const getRelevantTime = useCallback(() => (playingRef.current ? videoRef.current!.currentTime : commandedTimeRef.current) || 0, []); + const seekRel = useCallback((val: number) => { + seekAbs(getRelevantTime() + val); + }, [getRelevantTime, seekAbs]); + const onPlayingChange = useCallback((val: boolean) => { playingRef.current = val; setPlaying(val);