mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Show current time on timeline
This commit is contained in:
parent
3ec2745eeb
commit
509a5bd245
@ -29,6 +29,7 @@ type PreviewPlayerProps = {
|
|||||||
autoPlayback?: boolean;
|
autoPlayback?: boolean;
|
||||||
setReviewed?: (reviewId: string) => void;
|
setReviewed?: (reviewId: string) => void;
|
||||||
onClick?: (reviewId: string) => void;
|
onClick?: (reviewId: string) => void;
|
||||||
|
onTimeUpdate?: (time: number | undefined) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Preview = {
|
type Preview = {
|
||||||
@ -44,6 +45,7 @@ export default function PreviewThumbnailPlayer({
|
|||||||
relevantPreview,
|
relevantPreview,
|
||||||
setReviewed,
|
setReviewed,
|
||||||
onClick,
|
onClick,
|
||||||
|
onTimeUpdate,
|
||||||
}: PreviewPlayerProps) {
|
}: PreviewPlayerProps) {
|
||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
@ -62,7 +64,7 @@ export default function PreviewThumbnailPlayer({
|
|||||||
}, [ignoreClick, review, onClick]);
|
}, [ignoreClick, review, onClick]);
|
||||||
|
|
||||||
const swipeHandlers = useSwipeable({
|
const swipeHandlers = useSwipeable({
|
||||||
onSwipedLeft: () => setPlayback(false),
|
onSwipedLeft: () => (setReviewed ? setReviewed(review.id) : null),
|
||||||
onSwipedRight: () => setPlayback(true),
|
onSwipedRight: () => setPlayback(true),
|
||||||
preventScrollOnSwipe: true,
|
preventScrollOnSwipe: true,
|
||||||
});
|
});
|
||||||
@ -92,6 +94,10 @@ export default function PreviewThumbnailPlayer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPlayback(false);
|
setPlayback(false);
|
||||||
|
|
||||||
|
if (onTimeUpdate) {
|
||||||
|
onTimeUpdate(undefined);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -125,6 +131,7 @@ export default function PreviewThumbnailPlayer({
|
|||||||
setReviewed={handleSetReviewed}
|
setReviewed={handleSetReviewed}
|
||||||
setIgnoreClick={setIgnoreClick}
|
setIgnoreClick={setIgnoreClick}
|
||||||
isPlayingBack={setPlayback}
|
isPlayingBack={setPlayback}
|
||||||
|
onTimeUpdate={onTimeUpdate}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -190,6 +197,7 @@ type PreviewContentProps = {
|
|||||||
setReviewed?: () => void;
|
setReviewed?: () => void;
|
||||||
setIgnoreClick: (ignore: boolean) => void;
|
setIgnoreClick: (ignore: boolean) => void;
|
||||||
isPlayingBack: (ended: boolean) => void;
|
isPlayingBack: (ended: boolean) => void;
|
||||||
|
onTimeUpdate?: (time: number | undefined) => void;
|
||||||
};
|
};
|
||||||
function PreviewContent({
|
function PreviewContent({
|
||||||
review,
|
review,
|
||||||
@ -197,6 +205,7 @@ function PreviewContent({
|
|||||||
setReviewed,
|
setReviewed,
|
||||||
setIgnoreClick,
|
setIgnoreClick,
|
||||||
isPlayingBack,
|
isPlayingBack,
|
||||||
|
onTimeUpdate,
|
||||||
}: PreviewContentProps) {
|
}: PreviewContentProps) {
|
||||||
// preview
|
// preview
|
||||||
|
|
||||||
@ -208,6 +217,7 @@ function PreviewContent({
|
|||||||
setReviewed={setReviewed}
|
setReviewed={setReviewed}
|
||||||
setIgnoreClick={setIgnoreClick}
|
setIgnoreClick={setIgnoreClick}
|
||||||
isPlayingBack={isPlayingBack}
|
isPlayingBack={isPlayingBack}
|
||||||
|
onTimeUpdate={onTimeUpdate}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (isCurrentHour(review.start_time)) {
|
} else if (isCurrentHour(review.start_time)) {
|
||||||
@ -217,6 +227,7 @@ function PreviewContent({
|
|||||||
setReviewed={setReviewed}
|
setReviewed={setReviewed}
|
||||||
setIgnoreClick={setIgnoreClick}
|
setIgnoreClick={setIgnoreClick}
|
||||||
isPlayingBack={isPlayingBack}
|
isPlayingBack={isPlayingBack}
|
||||||
|
onTimeUpdate={onTimeUpdate}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -229,6 +240,7 @@ type VideoPreviewProps = {
|
|||||||
setReviewed?: () => void;
|
setReviewed?: () => void;
|
||||||
setIgnoreClick: (ignore: boolean) => void;
|
setIgnoreClick: (ignore: boolean) => void;
|
||||||
isPlayingBack: (ended: boolean) => void;
|
isPlayingBack: (ended: boolean) => void;
|
||||||
|
onTimeUpdate?: (time: number | undefined) => void;
|
||||||
};
|
};
|
||||||
function VideoPreview({
|
function VideoPreview({
|
||||||
review,
|
review,
|
||||||
@ -236,6 +248,7 @@ function VideoPreview({
|
|||||||
setReviewed,
|
setReviewed,
|
||||||
setIgnoreClick,
|
setIgnoreClick,
|
||||||
isPlayingBack,
|
isPlayingBack,
|
||||||
|
onTimeUpdate,
|
||||||
}: VideoPreviewProps) {
|
}: VideoPreviewProps) {
|
||||||
const playerRef = useRef<HTMLVideoElement | null>(null);
|
const playerRef = useRef<HTMLVideoElement | null>(null);
|
||||||
|
|
||||||
@ -286,8 +299,10 @@ function VideoPreview({
|
|||||||
// time progress update
|
// time progress update
|
||||||
|
|
||||||
const onProgress = useCallback(() => {
|
const onProgress = useCallback(() => {
|
||||||
if (!setProgress) {
|
if (onTimeUpdate) {
|
||||||
return;
|
onTimeUpdate(
|
||||||
|
relevantPreview.start + (playerRef.current?.currentTime || 0),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const playerProgress =
|
const playerProgress =
|
||||||
@ -310,6 +325,10 @@ function VideoPreview({
|
|||||||
if (playerPercent > 100) {
|
if (playerPercent > 100) {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
isPlayingBack(false);
|
isPlayingBack(false);
|
||||||
|
|
||||||
|
if (onTimeUpdate) {
|
||||||
|
onTimeUpdate(undefined);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
playerRef.current?.pause();
|
playerRef.current?.pause();
|
||||||
}
|
}
|
||||||
@ -424,17 +443,19 @@ type InProgressPreviewProps = {
|
|||||||
setReviewed?: (reviewId: string) => void;
|
setReviewed?: (reviewId: string) => void;
|
||||||
setIgnoreClick: (ignore: boolean) => void;
|
setIgnoreClick: (ignore: boolean) => void;
|
||||||
isPlayingBack: (ended: boolean) => void;
|
isPlayingBack: (ended: boolean) => void;
|
||||||
|
onTimeUpdate?: (time: number | undefined) => void;
|
||||||
};
|
};
|
||||||
function InProgressPreview({
|
function InProgressPreview({
|
||||||
review,
|
review,
|
||||||
setReviewed,
|
setReviewed,
|
||||||
setIgnoreClick,
|
setIgnoreClick,
|
||||||
isPlayingBack,
|
isPlayingBack,
|
||||||
|
onTimeUpdate,
|
||||||
}: InProgressPreviewProps) {
|
}: InProgressPreviewProps) {
|
||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const { data: previewFrames } = useSWR<string[]>(
|
const { data: previewFrames } = useSWR<string[]>(
|
||||||
`preview/${review.camera}/start/${Math.floor(review.start_time) - 4}/end/${
|
`preview/${review.camera}/start/${Math.floor(review.start_time) - PREVIEW_PADDING}/end/${
|
||||||
Math.ceil(review.end_time) + 4
|
Math.ceil(review.end_time) + PREVIEW_PADDING
|
||||||
}/frames`,
|
}/frames`,
|
||||||
);
|
);
|
||||||
const [manualFrame, setManualFrame] = useState(false);
|
const [manualFrame, setManualFrame] = useState(false);
|
||||||
@ -445,6 +466,10 @@ function InProgressPreview({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onTimeUpdate) {
|
||||||
|
onTimeUpdate(review.start_time - PREVIEW_PADDING + key);
|
||||||
|
}
|
||||||
|
|
||||||
if (manualFrame) {
|
if (manualFrame) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -452,6 +477,10 @@ function InProgressPreview({
|
|||||||
if (key == previewFrames.length - 1) {
|
if (key == previewFrames.length - 1) {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
isPlayingBack(false);
|
isPlayingBack(false);
|
||||||
|
|
||||||
|
if (onTimeUpdate) {
|
||||||
|
onTimeUpdate(undefined);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -187,6 +187,10 @@ export default function EventView({
|
|||||||
return data;
|
return data;
|
||||||
}, [minimap]);
|
}, [minimap]);
|
||||||
|
|
||||||
|
// preview playback
|
||||||
|
|
||||||
|
const [previewTime, setPreviewTime] = useState<number>();
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
@ -287,6 +291,7 @@ export default function EventView({
|
|||||||
review={value}
|
review={value}
|
||||||
relevantPreview={relevantPreview}
|
relevantPreview={relevantPreview}
|
||||||
setReviewed={markItemAsReviewed}
|
setReviewed={markItemAsReviewed}
|
||||||
|
onTimeUpdate={setPreviewTime}
|
||||||
onClick={onSelectReview}
|
onClick={onSelectReview}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -308,6 +313,8 @@ export default function EventView({
|
|||||||
showMinimap={showMinimap}
|
showMinimap={showMinimap}
|
||||||
minimapStartTime={minimapBounds.start}
|
minimapStartTime={minimapBounds.start}
|
||||||
minimapEndTime={minimapBounds.end}
|
minimapEndTime={minimapBounds.end}
|
||||||
|
showHandlebar={previewTime != undefined}
|
||||||
|
handlebarTime={previewTime}
|
||||||
events={reviewItems.all}
|
events={reviewItems.all}
|
||||||
severityType={severity}
|
severityType={severity}
|
||||||
contentRef={contentRef}
|
contentRef={contentRef}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user