diff --git a/web/src/components/player/HlsVideoPlayer.tsx b/web/src/components/player/HlsVideoPlayer.tsx index c9f63f96d..5f499ade7 100644 --- a/web/src/components/player/HlsVideoPlayer.tsx +++ b/web/src/components/player/HlsVideoPlayer.tsx @@ -268,11 +268,30 @@ export default function HlsVideoPlayer({ onPlaying={onPlaying} onPause={() => { setIsPlaying(false); + clearTimeout(bufferTimeout); if (isMobile && mobileCtrlTimeout) { clearTimeout(mobileCtrlTimeout); } }} + onWaiting={() => { + if (onError != undefined) { + if (videoRef.current?.paused) { + return; + } + + setBufferTimeout( + setTimeout(() => { + if ( + document.visibilityState === "visible" && + videoRef.current + ) { + onError("stalled"); + } + }, 3000), + ); + } + }} onProgress={() => { if (onError != undefined) { if (videoRef.current?.paused) { @@ -283,18 +302,6 @@ export default function HlsVideoPlayer({ clearTimeout(bufferTimeout); setBufferTimeout(undefined); } - - setBufferTimeout( - setTimeout(() => { - if ( - document.visibilityState === "visible" && - videoRef.current && - !videoRef.current.paused - ) { - onError("stalled"); - } - }, 3000), - ); } }} onTimeUpdate={() =>