mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Small jsmpeg and mse player fixes (#12032)
This commit is contained in:
parent
4635e64b2e
commit
6c107883b5
@ -23,6 +23,7 @@ export default function JSMpegPlayer({
|
|||||||
}: JSMpegPlayerProps) {
|
}: JSMpegPlayerProps) {
|
||||||
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
|
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
|
||||||
const playerRef = useRef<HTMLDivElement | null>(null);
|
const playerRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const videoRef = useRef(null);
|
||||||
const internalContainerRef = useRef<HTMLDivElement | null>(null);
|
const internalContainerRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
const selectedContainerRef = useMemo(
|
const selectedContainerRef = useMemo(
|
||||||
@ -86,7 +87,7 @@ export default function JSMpegPlayer({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const video = new JSMpeg.VideoElement(
|
videoRef.current = new JSMpeg.VideoElement(
|
||||||
playerRef.current,
|
playerRef.current,
|
||||||
url,
|
url,
|
||||||
{ canvas: `#${CSS.escape(uniqueId)}` },
|
{ canvas: `#${CSS.escape(uniqueId)}` },
|
||||||
@ -99,17 +100,9 @@ export default function JSMpegPlayer({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
// we know that these deps are correct
|
||||||
return () => {
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
if (playerRef.current) {
|
}, [url, uniqueId]);
|
||||||
try {
|
|
||||||
video.destroy();
|
|
||||||
// eslint-disable-next-line no-empty
|
|
||||||
} catch (e) {}
|
|
||||||
playerRef.current = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [url, uniqueId, onPlaying]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
|
@ -260,10 +260,14 @@ function MSEPlayer({
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
onDisconnect();
|
onDisconnect();
|
||||||
|
if (bufferTimeout) {
|
||||||
|
clearTimeout(bufferTimeout);
|
||||||
|
setBufferTimeout(undefined);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// we know that these deps are correct
|
// we know that these deps are correct
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [playbackEnabled, onDisconnect, onConnect]);
|
}, [playbackEnabled]);
|
||||||
|
|
||||||
// check visibility
|
// check visibility
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user