import { h, Fragment } from 'preact'; import JSMpegPlayer from '../components/JSMpegPlayer'; import Heading from '../components/Heading'; import { useState } from 'preact/hooks'; import useSWR from 'swr'; import { Tabs, TextTab } from '../components/Tabs'; import { LiveChip } from '../components/LiveChip'; import { DebugCamera } from '../components/DebugCamera'; import HistoryViewer from '../components/HistoryViewer/HistoryViewer.tsx'; export default function Camera({ camera }) { const { data: config } = useSWR('config'); const [playerType, setPlayerType] = useState('live'); const cameraConfig = config?.cameras[camera]; const handleTabChange = (index) => { if (index === 0) { setPlayerType('history'); } else if (index === 1) { setPlayerType('live'); } else if (index === 2) { setPlayerType('debug'); } }; return (
{(playerType === 'live' || playerType === 'debug') && ( {camera} )}
); } const RenderPlayer = function ({ camera, cameraConfig, playerType }) { const liveWidth = Math.round(cameraConfig.live.height * (cameraConfig.detect.width / cameraConfig.detect.height)); if (playerType === 'live') { return (
); } else if (playerType === 'history') { return ; } else if (playerType === 'debug') { return ; } return ; };