Check websocket readyState for disconnect and fix firefox pip (#12216)

This commit is contained in:
Josh Hawkins
2024-06-30 07:04:45 -05:00
committed by GitHub
parent f0159bf41e
commit f9e1ad253f
3 changed files with 46 additions and 32 deletions

View File

@@ -128,12 +128,12 @@ function MSEPlayer({
setSafariPlaying(false);
}
if (wsRef.current && wsState != WebSocket.CLOSED) {
if (wsRef.current) {
setWsState(WebSocket.CLOSED);
wsRef.current.close();
wsRef.current = null;
}
}, [wsState, bufferTimeout, safariPlaying]);
}, [bufferTimeout, safariPlaying]);
const onOpen = () => {
setWsState(WebSocket.OPEN);
@@ -359,7 +359,7 @@ function MSEPlayer({
// ensure we disconnect for slower connections
useEffect(() => {
if (wsState === WebSocket.OPEN && !playbackEnabled) {
if (wsRef.current?.readyState === WebSocket.OPEN && !playbackEnabled) {
if (bufferTimeout) {
clearTimeout(bufferTimeout);
setBufferTimeout(undefined);