mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
Only disconnect instead of full remove
This commit is contained in:
parent
adc103ccc8
commit
8e9e03a936
@ -63,7 +63,7 @@ export default function LivePlayer({
|
|||||||
|
|
||||||
const stillReloadInterval = useMemo(() => {
|
const stillReloadInterval = useMemo(() => {
|
||||||
if (!windowVisible) {
|
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) {
|
if (liveReady) {
|
||||||
@ -96,6 +96,7 @@ export default function LivePlayer({
|
|||||||
<MSEPlayer
|
<MSEPlayer
|
||||||
className={`rounded-2xl h-full ${liveReady ? "" : "hidden"}`}
|
className={`rounded-2xl h-full ${liveReady ? "" : "hidden"}`}
|
||||||
camera={cameraConfig.name}
|
camera={cameraConfig.name}
|
||||||
|
playbackEnabled={cameraActive}
|
||||||
onPlaying={() => setLiveReady(true)}
|
onPlaying={() => setLiveReady(true)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -130,8 +131,7 @@ export default function LivePlayer({
|
|||||||
>
|
>
|
||||||
<div className="absolute top-0 left-0 right-0 rounded-2xl z-10 w-full h-[30%] bg-gradient-to-b from-black/20 to-transparent pointer-events-none"></div>
|
<div className="absolute top-0 left-0 right-0 rounded-2xl z-10 w-full h-[30%] bg-gradient-to-b from-black/20 to-transparent pointer-events-none"></div>
|
||||||
<div className="absolute bottom-0 left-0 right-0 rounded-2xl z-10 w-full h-[10%] bg-gradient-to-t from-black/20 to-transparent pointer-events-none"></div>
|
<div className="absolute bottom-0 left-0 right-0 rounded-2xl z-10 w-full h-[10%] bg-gradient-to-t from-black/20 to-transparent pointer-events-none"></div>
|
||||||
|
{player}
|
||||||
{(showStillWithoutActivity == false || cameraActive) && player}
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={`absolute left-0 top-0 right-0 bottom-0 w-full ${
|
className={`absolute left-0 top-0 right-0 bottom-0 w-full ${
|
||||||
|
|||||||
@ -4,10 +4,16 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|||||||
type MSEPlayerProps = {
|
type MSEPlayerProps = {
|
||||||
camera: string;
|
camera: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
playbackEnabled?: boolean;
|
||||||
onPlaying?: () => void;
|
onPlaying?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
function MSEPlayer({ camera, className, onPlaying }: MSEPlayerProps) {
|
function MSEPlayer({
|
||||||
|
camera,
|
||||||
|
className,
|
||||||
|
playbackEnabled = true,
|
||||||
|
onPlaying,
|
||||||
|
}: MSEPlayerProps) {
|
||||||
let connectTS: number = 0;
|
let connectTS: number = 0;
|
||||||
|
|
||||||
const RECONNECT_TIMEOUT: number = 30000;
|
const RECONNECT_TIMEOUT: number = 30000;
|
||||||
@ -203,6 +209,10 @@ function MSEPlayer({ camera, className, onPlaying }: MSEPlayerProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!playbackEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// iOS 17.1+ uses ManagedMediaSource
|
// iOS 17.1+ uses ManagedMediaSource
|
||||||
const MediaSourceConstructor =
|
const MediaSourceConstructor =
|
||||||
"ManagedMediaSource" in window ? window.ManagedMediaSource : MediaSource;
|
"ManagedMediaSource" in window ? window.ManagedMediaSource : MediaSource;
|
||||||
@ -236,18 +246,12 @@ function MSEPlayer({ camera, className, onPlaying }: MSEPlayerProps) {
|
|||||||
observer.observe(videoRef.current!);
|
observer.observe(videoRef.current!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
|
||||||
onDisconnect();
|
|
||||||
};
|
|
||||||
}, [onDisconnect, onConnect]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
onConnect();
|
onConnect();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
onDisconnect();
|
onDisconnect();
|
||||||
};
|
};
|
||||||
}, [wsURL]);
|
}, [playbackEnabled, onDisconnect, onConnect]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<video
|
<video
|
||||||
|
|||||||
@ -64,7 +64,7 @@ function Live() {
|
|||||||
.sort((aConf, bConf) => aConf.ui.order - bConf.ui.order);
|
.sort((aConf, bConf) => aConf.ui.order - bConf.ui.order);
|
||||||
}, [config]);
|
}, [config]);
|
||||||
|
|
||||||
const [windowVisible, setWindowVisible] = useState(false);
|
const [windowVisible, setWindowVisible] = useState(true);
|
||||||
const visibilityListener = useCallback(() => {
|
const visibilityListener = useCallback(() => {
|
||||||
setWindowVisible(document.visibilityState == "visible");
|
setWindowVisible(document.visibilityState == "visible");
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user