mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-12 01:57:36 +03:00
rework context provider
This commit is contained in:
parent
182df88adf
commit
89e082746d
@ -20,7 +20,6 @@ import { cn } from "@/lib/utils";
|
|||||||
import { ASPECT_VERTICAL_LAYOUT, RecordingPlayerError } from "@/types/record";
|
import { ASPECT_VERTICAL_LAYOUT, RecordingPlayerError } from "@/types/record";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ObjectTrackOverlay from "@/components/overlay/ObjectTrackOverlay";
|
import ObjectTrackOverlay from "@/components/overlay/ObjectTrackOverlay";
|
||||||
import { DetailStreamContextType } from "@/context/detail-stream-context";
|
|
||||||
|
|
||||||
// Android native hls does not seek correctly
|
// Android native hls does not seek correctly
|
||||||
const USE_NATIVE_HLS = !isAndroid;
|
const USE_NATIVE_HLS = !isAndroid;
|
||||||
@ -54,8 +53,11 @@ type HlsVideoPlayerProps = {
|
|||||||
onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined;
|
onUploadFrame?: (playTime: number) => Promise<AxiosResponse> | undefined;
|
||||||
toggleFullscreen?: () => void;
|
toggleFullscreen?: () => void;
|
||||||
onError?: (error: RecordingPlayerError) => void;
|
onError?: (error: RecordingPlayerError) => void;
|
||||||
detail?: Partial<DetailStreamContextType>;
|
isDetailMode?: boolean;
|
||||||
|
camera?: string;
|
||||||
|
currentTimeOverride?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function HlsVideoPlayer({
|
export default function HlsVideoPlayer({
|
||||||
videoRef,
|
videoRef,
|
||||||
containerRef,
|
containerRef,
|
||||||
@ -75,17 +77,15 @@ export default function HlsVideoPlayer({
|
|||||||
onUploadFrame,
|
onUploadFrame,
|
||||||
toggleFullscreen,
|
toggleFullscreen,
|
||||||
onError,
|
onError,
|
||||||
detail,
|
isDetailMode = false,
|
||||||
|
camera,
|
||||||
|
currentTimeOverride,
|
||||||
}: HlsVideoPlayerProps) {
|
}: HlsVideoPlayerProps) {
|
||||||
const { t } = useTranslation("components/player");
|
const { t } = useTranslation("components/player");
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
|
||||||
// for detail stream context in History
|
// for detail stream context in History
|
||||||
const selectedObjectId = detail?.selectedObjectId;
|
const currentTime = currentTimeOverride;
|
||||||
const selectedObjectTimeline = detail?.selectedObjectTimeline;
|
|
||||||
const currentTime = detail?.currentTime;
|
|
||||||
const camera = detail?.camera;
|
|
||||||
const isDetailMode = detail?.isDetailMode ?? false;
|
|
||||||
|
|
||||||
// playback
|
// playback
|
||||||
|
|
||||||
@ -316,16 +316,14 @@ export default function HlsVideoPlayer({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isDetailMode &&
|
{isDetailMode &&
|
||||||
selectedObjectId &&
|
|
||||||
camera &&
|
camera &&
|
||||||
currentTime &&
|
currentTime &&
|
||||||
videoDimensions.width > 0 &&
|
videoDimensions.width > 0 &&
|
||||||
videoDimensions.height > 0 && (
|
videoDimensions.height > 0 && (
|
||||||
<div className="absolute z-50 size-full">
|
<div className="absolute z-50 size-full">
|
||||||
<ObjectTrackOverlay
|
<ObjectTrackOverlay
|
||||||
key={`${selectedObjectId}-${currentTime}`}
|
key={`overlay-${currentTime}`}
|
||||||
camera={camera}
|
camera={camera}
|
||||||
selectedObjectId={selectedObjectId}
|
|
||||||
showBoundingBoxes={!isPlaying}
|
showBoundingBoxes={!isPlaying}
|
||||||
currentTime={currentTime}
|
currentTime={currentTime}
|
||||||
videoWidth={videoDimensions.width}
|
videoWidth={videoDimensions.width}
|
||||||
@ -336,7 +334,6 @@ export default function HlsVideoPlayer({
|
|||||||
onSeekToTime(timestamp, play);
|
onSeekToTime(timestamp, play);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
objectTimeline={selectedObjectTimeline}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -61,7 +61,11 @@ export default function DynamicVideoPlayer({
|
|||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
|
||||||
// for detail stream context in History
|
// for detail stream context in History
|
||||||
const detail = useDetailStream();
|
const {
|
||||||
|
isDetailMode,
|
||||||
|
camera: contextCamera,
|
||||||
|
currentTime,
|
||||||
|
} = useDetailStream();
|
||||||
|
|
||||||
// controlling playback
|
// controlling playback
|
||||||
|
|
||||||
@ -295,7 +299,9 @@ export default function DynamicVideoPlayer({
|
|||||||
setIsBuffering(true);
|
setIsBuffering(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
detail={detail}
|
isDetailMode={isDetailMode}
|
||||||
|
camera={contextCamera || camera}
|
||||||
|
currentTimeOverride={currentTime}
|
||||||
/>
|
/>
|
||||||
<PreviewPlayer
|
<PreviewPlayer
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user