Skip to content

NVR with realtime local object detection for IP cameras

Dynamically detect if full screen is supported (#13197)

Nicolas Mowen4974defe6faa
diff --git a/web/src/components/player/HlsVideoPlayer.tsx b/web/src/components/player/HlsVideoPlayer.tsx
index 5f499ade76..7f49a6cadc 100644
--- a/web/src/components/player/HlsVideoPlayer.tsx
+++ b/web/src/components/player/HlsVideoPlayer.tsx
@@ -6,7 +6,7 @@ import {
useState,
} from "react";
import Hls from "hls.js";
-import { isAndroid, isDesktop, isIOS, isMobile } from "react-device-detect";
+import { isAndroid, isDesktop, isMobile } from "react-device-detect";
import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
import VideoControls from "./VideoControls";
import { VideoResolutionType } from "@/types/live";
@@ -33,6 +33,7 @@ type HlsVideoPlayerProps = {
visible: boolean;
currentSource: string;
hotKeys: boolean;
+ supportsFullscreen: boolean;
fullscreen: boolean;
onClipEnded?: () => void;
onPlayerLoaded?: () => void;
@@ -49,6 +50,7 @@ export default function HlsVideoPlayer({
visible,
currentSource,
hotKeys,
+ supportsFullscreen,
fullscreen,
onClipEnded,
onPlayerLoaded,
@@ -180,7 +182,7 @@ export default function HlsVideoPlayer({
seek: true,
playbackRate: true,
plusUpload: config?.plus?.enabled == true,
- fullscreen: !isIOS,
+ fullscreen: supportsFullscreen,
}}
setControlsOpen={setControlsOpen}
setMuted={(muted) => setMuted(muted, true)}
diff --git a/web/src/components/player/dynamic/DynamicVideoPlayer.tsx b/web/src/components/player/dynamic/DynamicVideoPlayer.tsx
index caa709430f..6c4e28e27e 100644
--- a/web/src/components/player/dynamic/DynamicVideoPlayer.tsx
+++ b/web/src/components/player/dynamic/DynamicVideoPlayer.tsx
@@ -24,6 +24,7 @@ type DynamicVideoPlayerProps = {
startTimestamp?: number;
isScrubbing: boolean;
hotKeys: boolean;
+ supportsFullscreen: boolean;
fullscreen: boolean;
onControllerReady: (controller: DynamicVideoController) => void;
onTimestampUpdate?: (timestamp: number) => void;
@@ -40,6 +41,7 @@ export default function DynamicVideoPlayer({
startTimestamp,
isScrubbing,
hotKeys,
+ supportsFullscreen,
fullscreen,
onControllerReady,
onTimestampUpdate,
@@ -201,6 +203,7 @@ export default function DynamicVideoPlayer({
visible={!(isScrubbing || isLoading)}
currentSource={source}
hotKeys={hotKeys}
+ supportsFullscreen={supportsFullscreen}
fullscreen={fullscreen}
onTimeUpdate={onTimeUpdate}
onPlayerLoaded={onPlayerLoaded}
diff --git a/web/src/hooks/use-fullscreen.ts b/web/src/hooks/use-fullscreen.ts
index a0f0a1e56f..c7082ab5c7 100644
--- a/web/src/hooks/use-fullscreen.ts
+++ b/web/src/hooks/use-fullscreen.ts
@@ -1,4 +1,4 @@
-import { RefObject, useCallback, useEffect, useState } from "react";
+import { RefObject, useCallback, useEffect, useMemo, useState } from "react";
import nosleep from "nosleep.js";
const NoSleep = new nosleep();
@@ -147,5 +147,31 @@ export function useFullscreen<T extends HTMLElement = HTMLElement>(
}
}, [elementRef, handleFullscreenChange, handleFullscreenError]);
- return { fullscreen, toggleFullscreen, error, clearError };
+ // compatibility
+
+ const supportsFullScreen = useMemo<boolean>(() => {
+ // @ts-expect-error we need to check that fullscreen exists
+ if (document.exitFullscreen) return true;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ if ((document as any).msExitFullscreen)
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return true;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ if ((document as any).webkitExitFullscreen)
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return true;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ if ((document as any).mozCancelFullScreen)
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ return true;
+ return false;
+ }, []);
+
+ return {
+ fullscreen,
+ toggleFullscreen,
+ supportsFullScreen,
+ error,
+ clearError,
+ };
}
diff --git a/web/src/pages/Live.tsx b/web/src/pages/Live.tsx
index cd8cc6b0ae..c088a5b044 100644
--- a/web/src/pages/Live.tsx
+++ b/web/src/pages/Live.tsx
@@ -36,7 +36,8 @@ function Live() {
const mainRef = useRef<HTMLDivElement | null>(null);
- const { fullscreen, toggleFullscreen } = useFullscreen(mainRef);
+ const { fullscreen, toggleFullscreen, supportsFullScreen } =
+ useFullscreen(mainRef);
// document title
@@ -100,6 +101,7 @@ function Live() {
<div className="size-full" ref={mainRef}>
{selectedCameraName === "birdseye" ? (
<LiveBirdseyeView
+ supportsFullscreen={supportsFullScreen}
fullscreen={fullscreen}
toggleFullscreen={toggleFullscreen}
/>
@@ -107,6 +109,7 @@ function Live() {
<LiveCameraView
config={config}
camera={selectedCamera}
+ supportsFullscreen={supportsFullScreen}
fullscreen={fullscreen}
toggleFullscreen={toggleFullscreen}
/>
diff --git a/web/src/views/events/RecordingView.tsx b/web/src/views/events/RecordingView.tsx
index 1de3a690f1..f01da95788 100644
--- a/web/src/views/events/RecordingView.tsx
+++ b/web/src/views/events/RecordingView.tsx
@@ -257,7 +257,8 @@ export function RecordingView({
// fullscreen
- const { fullscreen, toggleFullscreen } = useFullscreen(mainLayoutRef);
+ const { fullscreen, toggleFullscreen, supportsFullScreen } =
+ useFullscreen(mainLayoutRef);
// layout
@@ -549,6 +550,7 @@ export function RecordingView({
mainControllerRef.current = controller;
}}
isScrubbing={scrubbing || exportMode == "timeline"}
+ supportsFullscreen={supportsFullScreen}
setFullResolution={setFullResolution}
toggleFullscreen={toggleFullscreen}
containerRef={mainLayoutRef}
diff --git a/web/src/views/live/LiveBirdseyeView.tsx b/web/src/views/live/LiveBirdseyeView.tsx
index 70e20e77a8..be69b43c8c 100644
--- a/web/src/views/live/LiveBirdseyeView.tsx
+++ b/web/src/views/live/LiveBirdseyeView.tsx
@@ -22,11 +22,13 @@ import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
import useSWR from "swr";
type LiveBirdseyeViewProps = {
+ supportsFullscreen: boolean;
fullscreen: boolean;
toggleFullscreen: () => void;
};
export default function LiveBirdseyeView({
+ supportsFullscreen,
fullscreen,
toggleFullscreen,
}: LiveBirdseyeViewProps) {
@@ -155,14 +157,16 @@ export default function LiveBirdseyeView({
<div
className={`mr-1 flex flex-row items-center gap-2 *:rounded-lg ${isMobile ? "landscape:flex-col" : ""}`}
>
- <CameraFeatureToggle
- className="p-2 md:p-0"
- variant={fullscreen ? "overlay" : "primary"}
- Icon={fullscreen ? FaCompress : FaExpand}
- isActive={fullscreen}
- title={fullscreen ? "Close" : "Fullscreen"}
- onClick={toggleFullscreen}
- />
+ {supportsFullscreen && (
+ <CameraFeatureToggle
+ className="p-2 md:p-0"
+ variant={fullscreen ? "overlay" : "primary"}
+ Icon={fullscreen ? FaCompress : FaExpand}
+ isActive={fullscreen}
+ title={fullscreen ? "Close" : "Fullscreen"}
+ onClick={toggleFullscreen}
+ />
+ )}
{!isIOS && !isFirefox && config.birdseye.restream && (
<CameraFeatureToggle
className="p-2 md:p-0"
diff --git a/web/src/views/live/LiveCameraView.tsx b/web/src/views/live/LiveCameraView.tsx
index 9dab7d9166..15e08cebf4 100644
--- a/web/src/views/live/LiveCameraView.tsx
+++ b/web/src/views/live/LiveCameraView.tsx
@@ -83,12 +83,14 @@ import { useSessionPersistence } from "@/hooks/use-session-persistence";
type LiveCameraViewProps = {
config?: FrigateConfig;
camera: CameraConfig;
+ supportsFullscreen: boolean;
fullscreen: boolean;
toggleFullscreen: () => void;
};
export default function LiveCameraView({
config,
camera,
+ supportsFullscreen,
fullscreen,
toggleFullscreen,
}: LiveCameraViewProps) {
@@ -376,7 +378,7 @@ export default function LiveCameraView({
)}
</Button>
)}
- {!isIOS && (
+ {supportsFullscreen && (
<CameraFeatureToggle
className="p-2 md:p-0"
variant={fullscreen ? "overlay" : "primary"}