mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
Add poster option to JSMpegPlayer for displaying a snapshot of the camera feed
This commit is contained in:
parent
186e6a4a34
commit
46752970b7
@ -6,12 +6,13 @@ import JSMpeg from '@cycjimmy/jsmpeg-player';
|
||||
export default function JSMpegPlayer({ camera, width, height }) {
|
||||
const playerRef = useRef();
|
||||
const url = `${baseUrl.replace(/^http/, 'ws')}live/jsmpeg/${camera}`;
|
||||
const snapshot = `${baseUrl}api/${camera}/latest.jpg?h=${height}`;
|
||||
|
||||
useEffect(() => {
|
||||
const video = new JSMpeg.VideoElement(
|
||||
playerRef.current,
|
||||
url,
|
||||
{},
|
||||
{poster: snapshot},
|
||||
{protocols: [], audio: false, videoBufferSize: 1024*1024*4}
|
||||
);
|
||||
|
||||
@ -29,7 +30,7 @@ export default function JSMpegPlayer({ camera, width, height }) {
|
||||
return () => {
|
||||
video.destroy();
|
||||
};
|
||||
}, [url]);
|
||||
}, [snapshot, url]);
|
||||
|
||||
return (
|
||||
<div ref={playerRef} class="jsmpeg" style={`max-height: ${height}px; max-width: ${width}px`} />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user