From 861ee0485d47d9a1441c9d825a39bdcbff4edd07 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 13 Jun 2021 14:21:20 -0500 Subject: [PATCH] swith camera view to jsmpeg --- web/src/components/JSMpegPlayer.jsx | 6 ++--- web/src/index.css | 4 ++++ web/src/routes/Camera.jsx | 35 +++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/web/src/components/JSMpegPlayer.jsx b/web/src/components/JSMpegPlayer.jsx index 323b30771..389d8a8da 100644 --- a/web/src/components/JSMpegPlayer.jsx +++ b/web/src/components/JSMpegPlayer.jsx @@ -5,14 +5,13 @@ import JSMpeg from '@cycjimmy/jsmpeg-player'; export default function JSMpegPlayer({ camera }) { const playerRef = useRef(); - const canvasRef = useRef(); const url = `${baseUrl.replace(/^http/, 'ws')}/live/${camera}` useEffect(() => { const video = new JSMpeg.VideoElement( playerRef.current, url, - {canvas: canvasRef.current}, + {}, {protocols: [], audio: false} ); @@ -22,8 +21,7 @@ export default function JSMpegPlayer({ camera }) { }, [url]); return ( -
- +
); } diff --git a/web/src/index.css b/web/src/index.css index d55a9aabc..1ccb2fad7 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -25,3 +25,7 @@ transform: rotate(360deg); } } + +.jsmpeg canvas { + position: static !important; +} diff --git a/web/src/routes/Camera.jsx b/web/src/routes/Camera.jsx index dab0350e4..fa83255c6 100644 --- a/web/src/routes/Camera.jsx +++ b/web/src/routes/Camera.jsx @@ -1,5 +1,6 @@ -import { h } from 'preact'; +import { h, Fragment } from 'preact'; import AutoUpdatingCameraImage from '../components/AutoUpdatingCameraImage'; +import JSMpegPlayer from '../components/JSMpegPlayer'; import Button from '../components/Button'; import Card from '../components/Card'; import Heading from '../components/Heading'; @@ -16,6 +17,7 @@ export default function Camera({ camera }) { const { data: config } = useConfig(); const apiHost = useApiHost(); const [showSettings, setShowSettings] = useState(false); + const [viewMode, setViewMode] = useState('live'); const cameraConfig = config?.cameras[camera]; const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject); @@ -79,9 +81,16 @@ export default function Camera({ camera }) {
) : null; - return ( -
- {camera} + let player; + if (viewMode == 'live') { + player = <> +
+ +
+ ; + } + else if (viewMode == 'debug') { + player = <>
@@ -93,6 +102,24 @@ export default function Camera({ camera }) { {showSettings ? 'Hide' : 'Show'} Options {showSettings ? : null} + ; + } + + return ( +
+ {camera} +
+ +
+ + {player}
Tracked objects