Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually set current time when selecting event #11948

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/src/components/player/PreviewPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function PreviewVideoPlayer({
</video>
{cameraPreviews && !currentPreview && (
<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>
)}
{firstLoad && <Skeleton className="absolute aspect-video size-full" />}
Expand Down Expand Up @@ -536,7 +536,7 @@ function PreviewFramesPlayer({
/>
{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">
No Preview Found
No Preview Found for {camera.replaceAll("_", " ")}
</div>
)}
{firstLoad && <Skeleton className="absolute aspect-video size-full" />}
Expand Down
23 changes: 20 additions & 3 deletions web/src/views/events/RecordingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ export function RecordingView({
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(() => {
if (!scrubbing) {
if (Math.abs(currentTime - playerTime) > 10) {
Expand Down Expand Up @@ -580,6 +593,7 @@ export function RecordingView({
currentTime={currentTime}
exportRange={exportMode == "timeline" ? exportRange : undefined}
setCurrentTime={setCurrentTime}
manuallySetCurrentTime={manuallySetCurrentTime}
setScrubbing={setScrubbing}
setExportRange={setExportRange}
/>
Expand All @@ -597,6 +611,7 @@ type TimelineProps = {
currentTime: number;
exportRange?: TimeRange;
setCurrentTime: React.Dispatch<React.SetStateAction<number>>;
manuallySetCurrentTime: (time: number, force: boolean) => void;
setScrubbing: React.Dispatch<React.SetStateAction<boolean>>;
setExportRange: (range: TimeRange) => void;
};
Expand All @@ -609,6 +624,7 @@ function Timeline({
currentTime,
exportRange,
setCurrentTime,
manuallySetCurrentTime,
setScrubbing,
setExportRange,
}: TimelineProps) {
Expand Down Expand Up @@ -693,9 +709,10 @@ function Timeline({
event={review}
currentTime={currentTime}
onClick={() => {
setScrubbing(true);
setCurrentTime(review.start_time - REVIEW_PADDING);
setScrubbing(false);
manuallySetCurrentTime(
review.start_time - REVIEW_PADDING,
true,
);
}}
/>
);
Expand Down
Loading