Use a longer hls timeout delay

This commit is contained in:
Zoe Roux 2023-09-11 00:18:01 +02:00
parent e79e568a4c
commit 1dd3e37a37

View File

@ -34,7 +34,7 @@ import { useAtomValue, useSetAtom, useAtom } from "jotai";
import { useYoshiki } from "yoshiki";
import SubtitleOctopus from "libass-wasm";
import { playAtom, PlayMode, playModeAtom, subtitleAtom } from "./state";
import Hls, { Level } from "hls.js";
import Hls, { Level, LoadPolicy } from "hls.js";
import { useTranslation } from "react-i18next";
import { Menu } from "@kyoo/primitives";
import toVttBlob from "srt-webvtt";
@ -54,6 +54,23 @@ let client_id = typeof window === "undefined" ? "ssr" : uuidv4();
const initHls = async (): Promise<Hls> => {
if (hls !== null) return hls;
const token = await getToken();
const loadPolicy: LoadPolicy = {
default: {
maxTimeToFirstByteMs: Infinity,
maxLoadTimeMs: 60_000,
timeoutRetry: {
maxNumRetry: 2,
retryDelayMs: 0,
maxRetryDelayMs: 0,
},
errorRetry: {
maxNumRetry: 1,
retryDelayMs: 0,
maxRetryDelayMs: 0,
},
}
};
hls = new Hls({
xhrSetup: (xhr) => {
if (token) xhr.setRequestHeader("Authorization", `Bearer: ${token}`);
@ -62,6 +79,12 @@ const initHls = async (): Promise<Hls> => {
autoStartLoad: false,
// debug: true,
startPosition: 0,
fragLoadPolicy: loadPolicy,
keyLoadPolicy: loadPolicy,
certLoadPolicy: loadPolicy,
playlistLoadPolicy: loadPolicy,
manifestLoadPolicy: loadPolicy,
steeringManifestLoadPolicy: loadPolicy,
});
// hls.currentLevel = hls.startLevel;
return hls;