fix more progress

This commit is contained in:
Jelle van Snik 2023-02-07 23:26:40 +01:00
parent f8b5c4169c
commit d8e2597db7

View File

@ -15,6 +15,11 @@ export function ProgressAction() {
const videoTime = useProgress(descriptor); const videoTime = useProgress(descriptor);
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const dragRef = useRef<boolean>(false); const dragRef = useRef<boolean>(false);
const controlRef = useRef<typeof controls>(controls);
useEffect(() => {
controlRef.current = controls;
}, [controls]);
const commitTime = useCallback( const commitTime = useCallback(
(percentage) => { (percentage) => {
@ -36,11 +41,11 @@ export function ProgressAction() {
useEffect(() => { useEffect(() => {
if (dragging) { if (dragging) {
const state = getPlayerState(descriptor); const state = getPlayerState(descriptor);
controls.setDraggingTime( controlRef.current.setDraggingTime(
state.progress.duration * (dragPercentage / 100) state.progress.duration * (dragPercentage / 100)
); );
} }
}, [descriptor, dragging, dragPercentage, controls]); }, [descriptor, dragging, dragPercentage]);
let watchProgress = makePercentageString( let watchProgress = makePercentageString(
makePercentage((videoTime.time / videoTime.duration) * 100) makePercentage((videoTime.time / videoTime.duration) * 100)