mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-24 19:32:29 +01:00
fix seek jerkiness
This commit is contained in:
parent
85a900e15b
commit
4b65d27728
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user