Manually set current time when selecting event (#11948)

* Manually set current time when selecting event

* Make it clear which camera has no preview

* Make it clear which camera has no preview

* Format camera name
This commit is contained in:
Nicolas Mowen 2024-06-13 19:00:41 -05:00 committed by GitHub
parent 1a0d9e10d7
commit a7da468b97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 5 deletions

View File

@ -323,7 +323,7 @@ function PreviewVideoPlayer({
</video> </video>
{cameraPreviews && !currentPreview && ( {cameraPreviews && !currentPreview && (
<div className="absolute inset-0 flex items-center justify-center rounded-lg bg-background_alt text-primary md:rounded-2xl"> <div className="absolute inset-0 flex items-center justify-center rounded-lg bg-background_alt text-primary md:rounded-2xl">
No Preview Found No Preview Found for {camera.replaceAll("_", " ")}
</div> </div>
)} )}
{firstLoad && <Skeleton className="absolute aspect-video size-full" />} {firstLoad && <Skeleton className="absolute aspect-video size-full" />}
@ -536,7 +536,7 @@ function PreviewFramesPlayer({
/> />
{previewFrames?.length === 0 && ( {previewFrames?.length === 0 && (
<div className="-y-translate-1/2 align-center absolute inset-x-0 top-1/2 rounded-lg bg-background_alt text-center text-primary md:rounded-2xl"> <div className="-y-translate-1/2 align-center absolute inset-x-0 top-1/2 rounded-lg bg-background_alt text-center text-primary md:rounded-2xl">
No Preview Found No Preview Found for {camera.replaceAll("_", " ")}
</div> </div>
)} )}
{firstLoad && <Skeleton className="absolute aspect-video size-full" />} {firstLoad && <Skeleton className="absolute aspect-video size-full" />}

View File

@ -196,6 +196,19 @@ export function RecordingView({
updateSelectedSegment, updateSelectedSegment,
]); ]);
const manuallySetCurrentTime = useCallback(
(time: number) => {
setCurrentTime(time);
if (currentTimeRange.after <= time && currentTimeRange.before >= time) {
mainControllerRef.current?.seekToTimestamp(time, true);
} else {
updateSelectedSegment(time, true);
}
},
[currentTimeRange, updateSelectedSegment],
);
useEffect(() => { useEffect(() => {
if (!scrubbing) { if (!scrubbing) {
if (Math.abs(currentTime - playerTime) > 10) { if (Math.abs(currentTime - playerTime) > 10) {
@ -580,6 +593,7 @@ export function RecordingView({
currentTime={currentTime} currentTime={currentTime}
exportRange={exportMode == "timeline" ? exportRange : undefined} exportRange={exportMode == "timeline" ? exportRange : undefined}
setCurrentTime={setCurrentTime} setCurrentTime={setCurrentTime}
manuallySetCurrentTime={manuallySetCurrentTime}
setScrubbing={setScrubbing} setScrubbing={setScrubbing}
setExportRange={setExportRange} setExportRange={setExportRange}
/> />
@ -597,6 +611,7 @@ type TimelineProps = {
currentTime: number; currentTime: number;
exportRange?: TimeRange; exportRange?: TimeRange;
setCurrentTime: React.Dispatch<React.SetStateAction<number>>; setCurrentTime: React.Dispatch<React.SetStateAction<number>>;
manuallySetCurrentTime: (time: number, force: boolean) => void;
setScrubbing: React.Dispatch<React.SetStateAction<boolean>>; setScrubbing: React.Dispatch<React.SetStateAction<boolean>>;
setExportRange: (range: TimeRange) => void; setExportRange: (range: TimeRange) => void;
}; };
@ -609,6 +624,7 @@ function Timeline({
currentTime, currentTime,
exportRange, exportRange,
setCurrentTime, setCurrentTime,
manuallySetCurrentTime,
setScrubbing, setScrubbing,
setExportRange, setExportRange,
}: TimelineProps) { }: TimelineProps) {
@ -693,9 +709,10 @@ function Timeline({
event={review} event={review}
currentTime={currentTime} currentTime={currentTime}
onClick={() => { onClick={() => {
setScrubbing(true); manuallySetCurrentTime(
setCurrentTime(review.start_time - REVIEW_PADDING); review.start_time - REVIEW_PADDING,
setScrubbing(false); true,
);
}} }}
/> />
); );