mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Show motion playback on page initially (#11196)
* motion video controls handle current time better * Make sure state is updated
This commit is contained in:
parent
2e63941598
commit
28dd871d44
@ -8,7 +8,8 @@ export function useOverlayState<S>(
|
|||||||
): [S | undefined, (value: S, replace?: boolean) => void] {
|
): [S | undefined, (value: S, replace?: boolean) => void] {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const currentLocationState = location.state;
|
|
||||||
|
const currentLocationState = useMemo(() => location.state, [location]);
|
||||||
|
|
||||||
const setOverlayStateValue = useCallback(
|
const setOverlayStateValue = useCallback(
|
||||||
(value: S, replace: boolean = false) => {
|
(value: S, replace: boolean = false) => {
|
||||||
@ -18,7 +19,7 @@ export function useOverlayState<S>(
|
|||||||
},
|
},
|
||||||
// we know that these deps are correct
|
// we know that these deps are correct
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[key, navigate],
|
[key, currentLocationState, navigate],
|
||||||
);
|
);
|
||||||
|
|
||||||
const overlayStateValue = useMemo<S | undefined>(
|
const overlayStateValue = useMemo<S | undefined>(
|
||||||
@ -39,7 +40,8 @@ export function usePersistedOverlayState<S extends string>(
|
|||||||
);
|
);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const currentLocationState = location.state;
|
|
||||||
|
const currentLocationState = useMemo(() => location.state, [location]);
|
||||||
|
|
||||||
const setOverlayStateValue = useCallback(
|
const setOverlayStateValue = useCallback(
|
||||||
(value: S | undefined, replace: boolean = false) => {
|
(value: S | undefined, replace: boolean = false) => {
|
||||||
@ -50,7 +52,7 @@ export function usePersistedOverlayState<S extends string>(
|
|||||||
},
|
},
|
||||||
// we know that these deps are correct
|
// we know that these deps are correct
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[key, navigate],
|
[key, currentLocationState, navigate],
|
||||||
);
|
);
|
||||||
|
|
||||||
const overlayStateValue = useMemo<S | undefined>(
|
const overlayStateValue = useMemo<S | undefined>(
|
||||||
|
@ -805,6 +805,11 @@ function MotionReview({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextTimestamp >= timeRange.before - 4) {
|
||||||
|
setPlaying(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const handleTimeout = () => {
|
const handleTimeout = () => {
|
||||||
setCurrentTime(nextTimestamp);
|
setCurrentTime(nextTimestamp);
|
||||||
timeoutIdRef.current = setTimeout(handleTimeout, 500 / playbackRate);
|
timeoutIdRef.current = setTimeout(handleTimeout, 500 / playbackRate);
|
||||||
@ -818,7 +823,7 @@ function MotionReview({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [playing, playbackRate, nextTimestamp]);
|
}, [playing, playbackRate, nextTimestamp, setPlaying, timeRange]);
|
||||||
|
|
||||||
const { alignStartDateToTimeline } = useTimelineUtils({
|
const { alignStartDateToTimeline } = useTimelineUtils({
|
||||||
segmentDuration,
|
segmentDuration,
|
||||||
@ -962,7 +967,6 @@ function MotionReview({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!scrubbing && (
|
|
||||||
<VideoControls
|
<VideoControls
|
||||||
className="absolute bottom-16 left-1/2 -translate-x-1/2 bg-secondary"
|
className="absolute bottom-16 left-1/2 -translate-x-1/2 bg-secondary"
|
||||||
features={{
|
features={{
|
||||||
@ -971,6 +975,7 @@ function MotionReview({
|
|||||||
playbackRate: true,
|
playbackRate: true,
|
||||||
}}
|
}}
|
||||||
isPlaying={playing}
|
isPlaying={playing}
|
||||||
|
show={!scrubbing}
|
||||||
playbackRates={[4, 8, 12, 16]}
|
playbackRates={[4, 8, 12, 16]}
|
||||||
playbackRate={playbackRate}
|
playbackRate={playbackRate}
|
||||||
controlsOpen={controlsOpen}
|
controlsOpen={controlsOpen}
|
||||||
@ -990,9 +995,7 @@ function MotionReview({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onSetPlaybackRate={setPlaybackRate}
|
onSetPlaybackRate={setPlaybackRate}
|
||||||
show={currentTime < timeRange.before - 4}
|
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user