From 47aecff567bcea4a831e31ed193cecb177b227fb Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 23 Jul 2024 08:34:38 -0600 Subject: [PATCH] UI Tweaks (#12571) --- .../components/player/BirdseyeLivePlayer.tsx | 8 +++-- web/src/views/live/LiveBirdseyeView.tsx | 32 ++++++++++++++++++- web/src/views/live/LiveCameraView.tsx | 4 +-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/web/src/components/player/BirdseyeLivePlayer.tsx b/web/src/components/player/BirdseyeLivePlayer.tsx index 07fbcdbfb..2666ac9f7 100644 --- a/web/src/components/player/BirdseyeLivePlayer.tsx +++ b/web/src/components/player/BirdseyeLivePlayer.tsx @@ -11,16 +11,18 @@ type LivePlayerProps = { className?: string; birdseyeConfig: BirdseyeConfig; liveMode: LivePlayerMode; - onClick?: () => void; + pip?: boolean; containerRef: React.MutableRefObject; + onClick?: () => void; }; export default function BirdseyeLivePlayer({ className, birdseyeConfig, liveMode, - onClick, + pip, containerRef, + onClick, }: LivePlayerProps) { let player; if (liveMode == "webrtc") { @@ -28,6 +30,7 @@ export default function BirdseyeLivePlayer({ ); } else if (liveMode == "mse") { @@ -36,6 +39,7 @@ export default function BirdseyeLivePlayer({ ); } else { diff --git a/web/src/views/live/LiveBirdseyeView.tsx b/web/src/views/live/LiveBirdseyeView.tsx index 01146f643..70e20e77a 100644 --- a/web/src/views/live/LiveBirdseyeView.tsx +++ b/web/src/views/live/LiveBirdseyeView.tsx @@ -5,15 +5,18 @@ import { Button } from "@/components/ui/button"; import { TooltipProvider } from "@/components/ui/tooltip"; import { useResizeObserver } from "@/hooks/resize-observer"; import { FrigateConfig } from "@/types/frigateConfig"; -import { useMemo, useRef } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { isDesktop, + isFirefox, + isIOS, isMobile, isSafari, useMobileOrientation, } from "react-device-detect"; import { FaCompress, FaExpand } from "react-icons/fa"; import { IoMdArrowBack } from "react-icons/io"; +import { LuPictureInPicture } from "react-icons/lu"; import { useNavigate } from "react-router-dom"; import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"; import useSWR from "swr"; @@ -35,8 +38,17 @@ export default function LiveBirdseyeView({ const [{ width: windowWidth, height: windowHeight }] = useResizeObserver(window); + // pip state + + useEffect(() => { + setPip(document.pictureInPictureElement != null); + // we know that these deps are correct + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [document.pictureInPictureElement]); + // playback state + const [pip, setPip] = useState(false); const cameraAspectRatio = useMemo(() => { if (!config) { return 16 / 9; @@ -151,6 +163,23 @@ export default function LiveBirdseyeView({ title={fullscreen ? "Close" : "Fullscreen"} onClick={toggleFullscreen} /> + {!isIOS && !isFirefox && config.birdseye.restream && ( + { + if (!pip) { + setPip(true); + } else { + document.exitPictureInPicture(); + setPip(false); + } + }} + /> + )} @@ -177,6 +206,7 @@ export default function LiveBirdseyeView({ birdseyeConfig={config.birdseye} liveMode={preferredLiveMode} containerRef={containerRef} + pip={pip} /> diff --git a/web/src/views/live/LiveCameraView.tsx b/web/src/views/live/LiveCameraView.tsx index 61cf7d42f..033b0d71c 100644 --- a/web/src/views/live/LiveCameraView.tsx +++ b/web/src/views/live/LiveCameraView.tsx @@ -372,7 +372,7 @@ export default function LiveCameraView({ onClick={toggleFullscreen} /> )} - {!isIOS && !isFirefox && ( + {!isIOS && !isFirefox && preferredLiveMode != "jsmpeg" && (