mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45:25 +03:00
Show message when no reordings found for time
This commit is contained in:
parent
df1a10294c
commit
98cb723e49
@ -1,7 +1,7 @@
|
||||
import { Recording } from "@/types/record";
|
||||
import { DynamicPlayback } from "@/types/playback";
|
||||
import { PreviewController } from "../PreviewPlayer";
|
||||
import { Timeline } from "@/types/timeline";
|
||||
import { TimeRange, Timeline } from "@/types/timeline";
|
||||
|
||||
type PlayerMode = "playback" | "scrubbing";
|
||||
|
||||
@ -10,11 +10,13 @@ export class DynamicVideoController {
|
||||
public camera = "";
|
||||
private playerController: HTMLVideoElement;
|
||||
private previewController: PreviewController;
|
||||
private setNoRecording: (noRecs: boolean) => void;
|
||||
private setFocusedItem: (timeline: Timeline) => void;
|
||||
private playerMode: PlayerMode = "playback";
|
||||
|
||||
// playback
|
||||
private recordings: Recording[] = [];
|
||||
private timeRange: TimeRange = { after: 0, before: 0 };
|
||||
private annotationOffset: number;
|
||||
private timeToStart: number | undefined = undefined;
|
||||
|
||||
@ -24,6 +26,7 @@ export class DynamicVideoController {
|
||||
previewController: PreviewController,
|
||||
annotationOffset: number,
|
||||
defaultMode: PlayerMode,
|
||||
setNoRecording: (noRecs: boolean) => void,
|
||||
setFocusedItem: (timeline: Timeline) => void,
|
||||
) {
|
||||
this.camera = camera;
|
||||
@ -31,11 +34,13 @@ export class DynamicVideoController {
|
||||
this.previewController = previewController;
|
||||
this.annotationOffset = annotationOffset;
|
||||
this.playerMode = defaultMode;
|
||||
this.setNoRecording = setNoRecording;
|
||||
this.setFocusedItem = setFocusedItem;
|
||||
}
|
||||
|
||||
newPlayback(newPlayback: DynamicPlayback) {
|
||||
this.recordings = newPlayback.recordings;
|
||||
this.timeRange = newPlayback.timeRange;
|
||||
|
||||
if (this.timeToStart) {
|
||||
this.seekToTimestamp(this.timeToStart);
|
||||
@ -52,12 +57,17 @@ export class DynamicVideoController {
|
||||
}
|
||||
|
||||
seekToTimestamp(time: number, play: boolean = false) {
|
||||
if (time < this.timeRange.after || time > this.timeRange.before) {
|
||||
this.timeToStart = time;
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
this.recordings.length == 0 ||
|
||||
time < this.recordings[0].start_time ||
|
||||
time > this.recordings[this.recordings.length - 1].end_time
|
||||
) {
|
||||
this.timeToStart = time;
|
||||
this.setNoRecording(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,6 +100,8 @@ export class DynamicVideoController {
|
||||
} else {
|
||||
this.playerController.pause();
|
||||
}
|
||||
} else {
|
||||
console.log(`seek time is 0`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ export default function DynamicVideoPlayer({
|
||||
const playerRef = useRef<HTMLVideoElement | null>(null);
|
||||
const [previewController, setPreviewController] =
|
||||
useState<PreviewController | null>(null);
|
||||
const [noRecording, setNoRecording] = useState(false);
|
||||
const controller = useMemo(() => {
|
||||
if (!config || !playerRef.current || !previewController) {
|
||||
return undefined;
|
||||
@ -56,6 +57,7 @@ export default function DynamicVideoPlayer({
|
||||
previewController,
|
||||
(config.cameras[camera]?.detect?.annotation_offset || 0) / 1000,
|
||||
isScrubbing ? "scrubbing" : "playback",
|
||||
setNoRecording,
|
||||
() => {},
|
||||
);
|
||||
// we only want to fire once when players are ready
|
||||
@ -92,9 +94,11 @@ export default function DynamicVideoPlayer({
|
||||
|
||||
return () => {
|
||||
if (loadingTimeout) {
|
||||
clearTimeout(loadingTimeout)
|
||||
clearTimeout(loadingTimeout);
|
||||
}
|
||||
}
|
||||
};
|
||||
// we only want trigger when scrubbing state changes
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [camera, isScrubbing]);
|
||||
|
||||
const onPlayerLoaded = useCallback(() => {
|
||||
@ -149,6 +153,7 @@ export default function DynamicVideoPlayer({
|
||||
|
||||
controller.newPlayback({
|
||||
recordings: recordings ?? [],
|
||||
timeRange,
|
||||
});
|
||||
|
||||
// we only want this to change when recordings update
|
||||
@ -175,6 +180,7 @@ export default function DynamicVideoPlayer({
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
setNoRecording(false);
|
||||
}}
|
||||
/>
|
||||
<PreviewPlayer
|
||||
@ -188,9 +194,14 @@ export default function DynamicVideoPlayer({
|
||||
setPreviewController(previewController);
|
||||
}}
|
||||
/>
|
||||
{isLoading && (
|
||||
{isLoading && !noRecording && (
|
||||
<ActivityIndicator className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
|
||||
)}
|
||||
{noRecording && (
|
||||
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
|
||||
No recordings found for this time
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import { TimeRange } from "./timeline";
|
||||
|
||||
export type DynamicPlayback = {
|
||||
recordings: Recording[];
|
||||
timeRange: TimeRange;
|
||||
};
|
||||
|
||||
export type PreviewPlayback = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user