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

UI improvements #11429

Merged
merged 4 commits into from
May 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions web/src/components/player/HlsVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ export default function HlsVideoPlayer({
) {
setLoadedMetadata(false);
setUseHlsCompat(true);
} else {
toast.error(
// @ts-expect-error code does exist
`Failed to play recordings (error ${e.target.error.code}): ${e.target.error.message}`,
{
position: "top-center",
},
);
}
}}
/>
Expand Down
7 changes: 6 additions & 1 deletion web/src/components/player/PreviewPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export default function PreviewPlayer({
}

return (
<div className="flex size-full items-center justify-center rounded-lg text-white md:rounded-2xl">
<div
className={cn(
"flex size-full items-center justify-center rounded-lg text-white md:rounded-2xl",
className,
)}
>
No Preview Found
</div>
);
Expand Down
9 changes: 7 additions & 2 deletions web/src/components/player/VideoControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export default function VideoControls({
onSeek(10);
}
break;
case "f":
if (setFullscreen && down && !repeat) {
setFullscreen(!fullscreen);
}
break;
case "m":
if (setMuted && down && !repeat && video) {
setMuted(!muted);
Expand All @@ -157,10 +162,10 @@ export default function VideoControls({
},
// only update when preview only changes
// eslint-disable-next-line react-hooks/exhaustive-deps
[video, isPlaying, onSeek],
[video, isPlaying, fullscreen, setFullscreen, onSeek],
);
useKeyboardListener(
hotKeys ? ["ArrowLeft", "ArrowRight", "m", " "] : [],
hotKeys ? ["ArrowLeft", "ArrowRight", "f", "m", " "] : [],
onKeyboardShortcut,
);

Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Live.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Live() {
}

if (selectedCamera) {
return <LiveCameraView camera={selectedCamera} />;
return <LiveCameraView config={config} camera={selectedCamera} />;
}

return (
Expand Down
19 changes: 16 additions & 3 deletions web/src/views/live/LiveCameraView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import { TooltipProvider } from "@/components/ui/tooltip";
import { useResizeObserver } from "@/hooks/resize-observer";
import useKeyboardListener from "@/hooks/use-keyboard-listener";
import { CameraConfig } from "@/types/frigateConfig";
import { CameraConfig, FrigateConfig } from "@/types/frigateConfig";
import { LiveStreamMetadata, VideoResolutionType } from "@/types/live";
import { CameraPtzInfo } from "@/types/ptz";
import { RecordingStartingPoint } from "@/types/record";
Expand Down Expand Up @@ -75,9 +75,13 @@ import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
import useSWR from "swr";

type LiveCameraViewProps = {
config?: FrigateConfig;
camera: CameraConfig;
};
export default function LiveCameraView({ camera }: LiveCameraViewProps) {
export default function LiveCameraView({
config,
camera,
}: LiveCameraViewProps) {
const navigate = useNavigate();
const { isPortrait } = useMobileOrientation();
const mainRef = useRef<HTMLDivElement | null>(null);
Expand All @@ -86,8 +90,17 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {

// supported features

const isRestreamed = useMemo(
() =>
config &&
Object.keys(config.go2rtc.streams || {}).includes(
camera.live.stream_name,
),
[camera, config],
);

const { data: cameraMetadata } = useSWR<LiveStreamMetadata>(
`go2rtc/streams/${camera.live.stream_name}`,
isRestreamed ? `go2rtc/streams/${camera.live.stream_name}` : null,
{
revalidateOnFocus: false,
},
Expand Down