diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index c190fe9d1..f6f9c535f 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -63,7 +63,7 @@ export default function LivePlayer({ const stillReloadInterval = useMemo(() => { if (!windowVisible) { - return -1; // no reason to update the image when the window is not visible + return -1; // no reason to update the image when the window is not visible } if (liveReady) { @@ -96,6 +96,7 @@ export default function LivePlayer({ setLiveReady(true)} /> ); @@ -130,8 +131,7 @@ export default function LivePlayer({ >
- - {(showStillWithoutActivity == false || cameraActive) && player} + {player}
void; }; -function MSEPlayer({ camera, className, onPlaying }: MSEPlayerProps) { +function MSEPlayer({ + camera, + className, + playbackEnabled = true, + onPlaying, +}: MSEPlayerProps) { let connectTS: number = 0; const RECONNECT_TIMEOUT: number = 30000; @@ -203,6 +209,10 @@ function MSEPlayer({ camera, className, onPlaying }: MSEPlayerProps) { }; useEffect(() => { + if (!playbackEnabled) { + return; + } + // iOS 17.1+ uses ManagedMediaSource const MediaSourceConstructor = "ManagedMediaSource" in window ? window.ManagedMediaSource : MediaSource; @@ -236,18 +246,12 @@ function MSEPlayer({ camera, className, onPlaying }: MSEPlayerProps) { observer.observe(videoRef.current!); } - return () => { - onDisconnect(); - }; - }, [onDisconnect, onConnect]); - - useEffect(() => { onConnect(); return () => { onDisconnect(); }; - }, [wsURL]); + }, [playbackEnabled, onDisconnect, onConnect]); return (