mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-28 10:56:52 +03:00
add snapshot download to History player (#23395)
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
This commit is contained in:
@@ -54,6 +54,7 @@ type HlsVideoPlayerProps = {
|
||||
setFullResolution?: React.Dispatch<React.SetStateAction<VideoResolutionType>>;
|
||||
onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined;
|
||||
getSnapshotUrl?: (playTime: number) => string | undefined;
|
||||
onSnapshot?: (playTime: number) => Promise<void> | void;
|
||||
toggleFullscreen?: () => void;
|
||||
onError?: (error: RecordingPlayerError) => void;
|
||||
isDetailMode?: boolean;
|
||||
@@ -80,6 +81,7 @@ export default function HlsVideoPlayer({
|
||||
setFullResolution,
|
||||
onUploadFrame,
|
||||
getSnapshotUrl,
|
||||
onSnapshot,
|
||||
toggleFullscreen,
|
||||
onError,
|
||||
isDetailMode = false,
|
||||
@@ -232,6 +234,7 @@ export default function HlsVideoPlayer({
|
||||
const [mobileCtrlTimeout, setMobileCtrlTimeout] = useState<NodeJS.Timeout>();
|
||||
const [controls, setControls] = useState(isMobile);
|
||||
const [controlsOpen, setControlsOpen] = useState(false);
|
||||
const [isSnapshotLoading, setIsSnapshotLoading] = useState(false);
|
||||
const [zoomScale, setZoomScale] = useState(1.0);
|
||||
const [videoDimensions, setVideoDimensions] = useState<{
|
||||
width: number;
|
||||
@@ -287,6 +290,21 @@ export default function HlsVideoPlayer({
|
||||
return currentTime + inpointOffset;
|
||||
}, [videoRef, inpointOffset]);
|
||||
|
||||
const handleSnapshot = useCallback(async () => {
|
||||
const frameTime = getVideoTime();
|
||||
|
||||
if (!frameTime || !onSnapshot) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSnapshotLoading(true);
|
||||
try {
|
||||
await onSnapshot(frameTime);
|
||||
} finally {
|
||||
setIsSnapshotLoading(false);
|
||||
}
|
||||
}, [getVideoTime, onSnapshot]);
|
||||
|
||||
return (
|
||||
<TransformWrapper
|
||||
minScale={1.0}
|
||||
@@ -310,6 +328,7 @@ export default function HlsVideoPlayer({
|
||||
seek: true,
|
||||
playbackRate: true,
|
||||
plusUpload: isAdmin && config?.plus?.enabled == true,
|
||||
snapshot: !!onSnapshot,
|
||||
fullscreen: supportsFullscreen,
|
||||
}}
|
||||
setControlsOpen={setControlsOpen}
|
||||
@@ -357,6 +376,8 @@ export default function HlsVideoPlayer({
|
||||
}
|
||||
}
|
||||
}}
|
||||
onSnapshot={onSnapshot ? handleSnapshot : undefined}
|
||||
snapshotLoading={isSnapshotLoading}
|
||||
fullscreen={fullscreen}
|
||||
toggleFullscreen={toggleFullscreen}
|
||||
containerRef={containerRef}
|
||||
|
||||
Reference in New Issue
Block a user