mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-12 22:25:24 +03:00
default to jsmpeg if webrtc times out
This commit is contained in:
parent
1b9e539903
commit
fbf1b5fd55
@ -138,6 +138,7 @@ export default function LivePlayer({
|
|||||||
iOSCompatFullScreen={iOSCompatFullScreen}
|
iOSCompatFullScreen={iOSCompatFullScreen}
|
||||||
onPlaying={() => setLiveReady(true)}
|
onPlaying={() => setLiveReady(true)}
|
||||||
pip={pip}
|
pip={pip}
|
||||||
|
onError={onError}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (liveMode == "mse") {
|
} else if (liveMode == "mse") {
|
||||||
|
|||||||
@ -316,8 +316,7 @@ function MSEPlayer({
|
|||||||
if (isSafari || isIOS) {
|
if (isSafari || isIOS) {
|
||||||
onPlaying?.();
|
onPlaying?.();
|
||||||
}
|
}
|
||||||
return onError != undefined
|
if (onError != undefined) {
|
||||||
? () => {
|
|
||||||
if (videoRef.current?.paused) {
|
if (videoRef.current?.paused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -333,7 +332,6 @@ function MSEPlayer({
|
|||||||
}, 3000),
|
}, 3000),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: undefined;
|
|
||||||
}}
|
}}
|
||||||
onError={(e) => {
|
onError={(e) => {
|
||||||
if (
|
if (
|
||||||
@ -349,6 +347,8 @@ function MSEPlayer({
|
|||||||
(isSafari || isIOS)
|
(isSafari || isIOS)
|
||||||
) {
|
) {
|
||||||
onError?.("mse-decode");
|
onError?.("mse-decode");
|
||||||
|
clearTimeout(bufferTimeout);
|
||||||
|
setBufferTimeout(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wsRef.current) {
|
if (wsRef.current) {
|
||||||
|
|||||||
@ -36,6 +36,7 @@ export default function WebRtcPlayer({
|
|||||||
const pcRef = useRef<RTCPeerConnection | undefined>();
|
const pcRef = useRef<RTCPeerConnection | undefined>();
|
||||||
const videoRef = useRef<HTMLVideoElement | null>(null);
|
const videoRef = useRef<HTMLVideoElement | null>(null);
|
||||||
const [bufferTimeout, setBufferTimeout] = useState<NodeJS.Timeout>();
|
const [bufferTimeout, setBufferTimeout] = useState<NodeJS.Timeout>();
|
||||||
|
const videoLoadTimeoutRef = useRef<NodeJS.Timeout>();
|
||||||
|
|
||||||
const PeerConnection = useCallback(
|
const PeerConnection = useCallback(
|
||||||
async (media: string) => {
|
async (media: string) => {
|
||||||
@ -193,6 +194,27 @@ export default function WebRtcPlayer({
|
|||||||
videoRef.current.requestPictureInPicture();
|
videoRef.current.requestPictureInPicture();
|
||||||
}, [pip, videoRef]);
|
}, [pip, videoRef]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
videoLoadTimeoutRef.current = setTimeout(() => {
|
||||||
|
onError?.("stalled");
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (videoLoadTimeoutRef.current) {
|
||||||
|
clearTimeout(videoLoadTimeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// we know that these deps are correct
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleLoadedData = () => {
|
||||||
|
if (videoLoadTimeoutRef.current) {
|
||||||
|
clearTimeout(videoLoadTimeoutRef.current);
|
||||||
|
}
|
||||||
|
onPlaying?.();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<video
|
<video
|
||||||
ref={videoRef}
|
ref={videoRef}
|
||||||
@ -201,7 +223,7 @@ export default function WebRtcPlayer({
|
|||||||
autoPlay
|
autoPlay
|
||||||
playsInline
|
playsInline
|
||||||
muted={!audioEnabled}
|
muted={!audioEnabled}
|
||||||
onLoadedData={onPlaying}
|
onLoadedData={handleLoadedData}
|
||||||
onProgress={
|
onProgress={
|
||||||
onError != undefined
|
onError != undefined
|
||||||
? () => {
|
? () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user