Fix buffering

This commit is contained in:
Nicolas Mowen 2024-07-17 07:32:52 -06:00
parent 44ad83dcb6
commit 56ed9b0fca

View File

@ -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={() =>