import { h, Fragment } from 'preact'; import JSMpegPlayer from '../components/JSMpegPlayer'; import Heading from '../components/Heading'; import { useState } from 'preact/hooks'; import { useConfig } from '../api'; import { Tabs, TextTab } from '../components/Tabs'; import { LiveChip } from '../components/LiveChip'; import HistoryViewer from '../components/HistoryViewer'; import { DebugCamera } from '../components/DebugCamera'; export default function Camera({ camera }) { const { data: config } = useConfig(); const [playerType, setPlayerType] = useState('live'); const cameraConfig = config?.cameras[camera]; const liveWidth = Math.round(cameraConfig.live.height * (cameraConfig.detect.width / cameraConfig.detect.height)); const RenderPlayer = () => { if (playerType === 'live') { return (
); } else if (playerType === 'history') { return ; } else if (playerType === 'debug') { return ; } return ; }; 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} )}
); }