From be9e606ae4d921cfccb71787569c122b9f3a9730 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:48:38 -0500 Subject: [PATCH] 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 --- web/src/components/player/MsePlayer.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/src/components/player/MsePlayer.tsx b/web/src/components/player/MsePlayer.tsx index 317520f57..ad2c10e24 100644 --- a/web/src/components/player/MsePlayer.tsx +++ b/web/src/components/player/MsePlayer.tsx @@ -45,7 +45,7 @@ function MSEPlayer({ ]; const visibilityCheck: boolean = !pip; - const [safariPlaying, setSafariPlaying] = useState(false); + const [isPlaying, setIsPlaying] = useState(false); const [wsState, setWsState] = useState(WebSocket.CLOSED); const [connectTS, setConnectTS] = useState(0); @@ -124,16 +124,14 @@ function MSEPlayer({ setBufferTimeout(undefined); } - if ((isSafari || isIOS) && safariPlaying) { - setSafariPlaying(false); - } + setIsPlaying(false); if (wsRef.current) { setWsState(WebSocket.CLOSED); wsRef.current.close(); wsRef.current = null; } - }, [bufferTimeout, safariPlaying]); + }, [bufferTimeout]); const onOpen = () => { setWsState(WebSocket.OPEN); @@ -382,12 +380,14 @@ function MSEPlayer({ onLoadedData={() => { handleLoadedMetadata?.(); onPlaying?.(); + setIsPlaying(true); }} muted={!audioEnabled} onPause={() => videoRef.current?.play()} onProgress={() => { - if ((isSafari || isIOS) && !safariPlaying) { - setSafariPlaying(true); + if (!isPlaying) { + setIsPlaying(true); + handleLoadedMetadata?.(); onPlaying?.(); } if (onError != undefined) {