mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Ensure MSE onPlaying always gets called, even if loadeddata never fires (#12271)
* Ensure MSE onPlaying always gets called, even if loadeddata never fires * Call handleLoadedMetadata too if not playing yet
This commit is contained in:
parent
fe9a3c9205
commit
be9e606ae4
@ -45,7 +45,7 @@ function MSEPlayer({
|
|||||||
];
|
];
|
||||||
|
|
||||||
const visibilityCheck: boolean = !pip;
|
const visibilityCheck: boolean = !pip;
|
||||||
const [safariPlaying, setSafariPlaying] = useState(false);
|
const [isPlaying, setIsPlaying] = useState(false);
|
||||||
|
|
||||||
const [wsState, setWsState] = useState<number>(WebSocket.CLOSED);
|
const [wsState, setWsState] = useState<number>(WebSocket.CLOSED);
|
||||||
const [connectTS, setConnectTS] = useState<number>(0);
|
const [connectTS, setConnectTS] = useState<number>(0);
|
||||||
@ -124,16 +124,14 @@ function MSEPlayer({
|
|||||||
setBufferTimeout(undefined);
|
setBufferTimeout(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isSafari || isIOS) && safariPlaying) {
|
setIsPlaying(false);
|
||||||
setSafariPlaying(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wsRef.current) {
|
if (wsRef.current) {
|
||||||
setWsState(WebSocket.CLOSED);
|
setWsState(WebSocket.CLOSED);
|
||||||
wsRef.current.close();
|
wsRef.current.close();
|
||||||
wsRef.current = null;
|
wsRef.current = null;
|
||||||
}
|
}
|
||||||
}, [bufferTimeout, safariPlaying]);
|
}, [bufferTimeout]);
|
||||||
|
|
||||||
const onOpen = () => {
|
const onOpen = () => {
|
||||||
setWsState(WebSocket.OPEN);
|
setWsState(WebSocket.OPEN);
|
||||||
@ -382,12 +380,14 @@ function MSEPlayer({
|
|||||||
onLoadedData={() => {
|
onLoadedData={() => {
|
||||||
handleLoadedMetadata?.();
|
handleLoadedMetadata?.();
|
||||||
onPlaying?.();
|
onPlaying?.();
|
||||||
|
setIsPlaying(true);
|
||||||
}}
|
}}
|
||||||
muted={!audioEnabled}
|
muted={!audioEnabled}
|
||||||
onPause={() => videoRef.current?.play()}
|
onPause={() => videoRef.current?.play()}
|
||||||
onProgress={() => {
|
onProgress={() => {
|
||||||
if ((isSafari || isIOS) && !safariPlaying) {
|
if (!isPlaying) {
|
||||||
setSafariPlaying(true);
|
setIsPlaying(true);
|
||||||
|
handleLoadedMetadata?.();
|
||||||
onPlaying?.();
|
onPlaying?.();
|
||||||
}
|
}
|
||||||
if (onError != undefined) {
|
if (onError != undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user