Live player fixes and improvements (#11855)

* Only set stalled error when player is visible

* Show activity indicator before live player starts playing

* remove comment

* keep gradients when still image is showing

* fix chips

* red dot and outline
This commit is contained in:
Josh Hawkins
2024-06-10 17:24:25 -06:00
committed by GitHub
parent 30b86271ea
commit 18d561da0e
4 changed files with 79 additions and 53 deletions
+11 -2
View File
@@ -10,6 +10,7 @@ type JSMpegPlayerProps = {
width: number;
height: number;
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
onPlaying?: () => void;
};
export default function JSMpegPlayer({
@@ -18,6 +19,7 @@ export default function JSMpegPlayer({
height,
className,
containerRef,
onPlaying,
}: JSMpegPlayerProps) {
const url = `${baseUrl.replace(/^http/, "ws")}live/jsmpeg/${camera}`;
const playerRef = useRef<HTMLDivElement | null>(null);
@@ -88,7 +90,14 @@ export default function JSMpegPlayer({
playerRef.current,
url,
{ canvas: `#${CSS.escape(uniqueId)}` },
{ protocols: [], audio: false, videoBufferSize: 1024 * 1024 * 4 },
{
protocols: [],
audio: false,
videoBufferSize: 1024 * 1024 * 4,
onPlay: () => {
onPlaying?.();
},
},
);
return () => {
@@ -100,7 +109,7 @@ export default function JSMpegPlayer({
playerRef.current = null;
}
};
}, [url, uniqueId]);
}, [url, uniqueId, onPlaying]);
return (
<div className={className}>