From 4d8d3cd22e131022d63910b00a162093819cc9c5 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 2 Apr 2024 06:45:16 -0600 Subject: [PATCH] Live view improvements (#10781) * Show frigate features in bottom sheet on mobile * Use flex wrap on mobile so the ptz icons are not cutoff * Support opening pip from live view * Remove unused --- web/src/components/player/LivePlayer.tsx | 4 + web/src/components/player/MsePlayer.tsx | 12 ++ web/src/components/player/WebRTCPlayer.tsx | 13 ++ web/src/views/live/LiveCameraView.tsx | 240 ++++++++++++++++----- 4 files changed, 215 insertions(+), 54 deletions(-) diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index a8fe5d3b1..22559105a 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -22,6 +22,7 @@ type LivePlayerProps = { playAudio?: boolean; micEnabled?: boolean; // only webrtc supports mic iOSCompatFullScreen?: boolean; + pip?: boolean; onClick?: () => void; }; @@ -35,6 +36,7 @@ export default function LivePlayer({ playAudio = false, micEnabled = false, iOSCompatFullScreen = false, + pip, onClick, }: LivePlayerProps) { // camera activity @@ -105,6 +107,7 @@ export default function LivePlayer({ microphoneEnabled={micEnabled} iOSCompatFullScreen={iOSCompatFullScreen} onPlaying={() => setLiveReady(true)} + pip={pip} /> ); } else if (liveMode == "mse") { @@ -116,6 +119,7 @@ export default function LivePlayer({ playbackEnabled={cameraActive} audioEnabled={playAudio} onPlaying={() => setLiveReady(true)} + pip={pip} /> ); } else { diff --git a/web/src/components/player/MsePlayer.tsx b/web/src/components/player/MsePlayer.tsx index 42ae9aab6..7c88780a8 100644 --- a/web/src/components/player/MsePlayer.tsx +++ b/web/src/components/player/MsePlayer.tsx @@ -6,6 +6,7 @@ type MSEPlayerProps = { className?: string; playbackEnabled?: boolean; audioEnabled?: boolean; + pip?: boolean; onPlaying?: () => void; }; @@ -14,6 +15,7 @@ function MSEPlayer({ className, playbackEnabled = true, audioEnabled = false, + pip = false, onPlaying, }: MSEPlayerProps) { let connectTS: number = 0; @@ -268,6 +270,16 @@ function MSEPlayer({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [playbackEnabled, onDisconnect, onConnect]); + // control pip + + useEffect(() => { + if (!videoRef.current || !pip) { + return; + } + + videoRef.current.requestPictureInPicture(); + }, [pip, videoRef]); + return (