From 33a1f82fe86dbfa5c4b894db485f873d963b356a Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:32:34 -0600 Subject: [PATCH] put stream selection inside dropdown on desktop --- web/src/views/live/LiveCameraView.tsx | 212 ++++++++++++++++++-------- 1 file changed, 147 insertions(+), 65 deletions(-) diff --git a/web/src/views/live/LiveCameraView.tsx b/web/src/views/live/LiveCameraView.tsx index 7b9f2f98a..a6f22664f 100644 --- a/web/src/views/live/LiveCameraView.tsx +++ b/web/src/views/live/LiveCameraView.tsx @@ -55,11 +55,11 @@ import { FaMicrophone, FaMicrophoneSlash, } from "react-icons/fa"; -import { CiStreamOff, CiStreamOn } from "react-icons/ci"; import { GiSpeaker, GiSpeakerOff } from "react-icons/gi"; import { TbViewfinder, TbViewfinderOff } from "react-icons/tb"; import { IoIosWarning, IoMdArrowRoundBack } from "react-icons/io"; import { + LuCog, LuEar, LuEarOff, LuHistory, @@ -69,6 +69,7 @@ import { } from "react-icons/lu"; import { MdNoPhotography, + MdOutlineRestartAlt, MdPersonOff, MdPersonSearch, MdPhotoCamera, @@ -87,13 +88,9 @@ import { SelectItem, SelectTrigger, } from "@/components/ui/select"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/components/ui/tooltip"; import { usePersistence } from "@/hooks/use-persistence"; -import { TooltipPortal } from "@radix-ui/react-tooltip"; +import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; type LiveCameraViewProps = { config?: FrigateConfig; @@ -489,6 +486,8 @@ export default function LiveCameraView({ preferredLiveMode={preferredLiveMode} playInBackground={playInBackground ?? false} setPlayInBackground={setPlayInBackground} + isRestreamed={isRestreamed ?? false} + setLowBandwidth={setLowBandwidth} /> @@ -790,6 +789,8 @@ type FrigateCameraFeaturesProps = { preferredLiveMode: string; playInBackground: boolean; setPlayInBackground: (value: boolean | undefined) => void; + isRestreamed: boolean; + setLowBandwidth: React.Dispatch>; }; function FrigateCameraFeatures({ camera, @@ -802,6 +803,8 @@ function FrigateCameraFeatures({ preferredLiveMode, playInBackground, setPlayInBackground, + isRestreamed, + setLowBandwidth, }: FrigateCameraFeaturesProps) { const { payload: detectState, send: sendDetect } = useDetectState( camera.name, @@ -866,54 +869,106 @@ function FrigateCameraFeatures({ } /> )} - setPlayInBackground(!playInBackground)} - /> - {Object.values(camera.live.streams).length > 1 && ( - { + setStreamName?.(value); + }} + > + + {Object.keys(camera.live.streams).find( + (key) => camera.live.streams[key] === streamName, + )} + - - - {Object.entries(camera.live.streams).map(([stream, name]) => ( - - {stream} - - ))} - - - + + + {Object.entries(camera.live.streams).map( + ([stream, name]) => ( + + {stream} + + ), + )} + + + + + {preferredLiveMode == "jsmpeg" && isRestreamed && ( +
+
+ + +

+ Live view is in low-bandwidth mode due to buffering + or stream errors. +

+
+ +
+ )} + + )} +
+
+ + + setPlayInBackground(checked) + } + /> +
+

+ Enable this option to continue streaming when the player is + hidden. +

+
+ + + )} ); @@ -973,16 +1028,9 @@ function FrigateCameraFeatures({ } /> )} - { - setPlayInBackground(checked); - }} - /> {Object.values(camera.live.streams).length > 1 && (
-
Live stream selection
+
Stream
+ {preferredLiveMode == "jsmpeg" && isRestreamed && ( +
+
+ + +

+ Live view is in low-bandwidth mode due to buffering or + stream errors. +

+
+ +
+ )}
)} + {isRestreamed && ( + <> + { + setPlayInBackground(checked); + }} + /> +

+ Enable this option to continue streaming when the player is + hidden. +

+ + )} );