import WebRtcPlayer from "./WebRTCPlayer"; import { CameraConfig } from "@/types/frigateConfig"; import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage"; import ActivityIndicator from "../ui/activity-indicator"; import { Button } from "../ui/button"; import { LuSettings } from "react-icons/lu"; import { useCallback, useMemo, useState } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; import { Switch } from "../ui/switch"; import { Label } from "../ui/label"; import { usePersistence } from "@/hooks/use-persistence"; import JSMpegPlayer from "./JSMpegPlayer"; const emptyObject = Object.freeze({}); type LivePlayerProps = { cameraConfig: CameraConfig; liveMode: string; }; type Options = { [key: string]: boolean }; export default function LivePlayer({ cameraConfig, liveMode, }: LivePlayerProps) { const [showSettings, setShowSettings] = useState(false); const [options, setOptions] = usePersistence( `${cameraConfig.name}-feed`, emptyObject ); const handleSetOption = useCallback( (id: string, value: boolean) => { console.log("Setting " + id + " to " + value); const newOptions = { ...options, [id]: value }; setOptions(newOptions); }, [options, setOptions] ); const searchParams = useMemo( () => new URLSearchParams( Object.keys(options).reduce((memo, key) => { //@ts-ignore we know this is correct memo.push([key, options[key] === true ? "1" : "0"]); return memo; }, []) ), [options] ); const handleToggleSettings = useCallback(() => { setShowSettings(!showSettings); }, [showSettings, setShowSettings]); if (liveMode == "webrtc") { return (