diff --git a/src/utils/video.ts b/src/utils/video.ts index b5947b6..de63ef7 100644 --- a/src/utils/video.ts +++ b/src/utils/video.ts @@ -25,8 +25,6 @@ export const initHls = (monitorVideoUrl, monitorVideoRef) => { manifestLoadingTimeOut: 5000, // m3u8 请求超时5秒 levelLoadingMaxRetry: 20, // ts 分片加载最多重试20次 levelLoadingRetryDelay: 500, - fragLoadingMaxRetry: 20, // 片段加载重试 - fragLoadingRetryDelay: 500, lowLatencyMode: false, // 关掉低延迟模式,更稳定 startLevel: -1 // 自动选择码率 }); @@ -40,28 +38,6 @@ export const initHls = (monitorVideoUrl, monitorVideoRef) => { // 加载成功,重置重试计数 // hlsRetryCount = 0; }); - - // ★ 错误自动恢复:hls.js 拿到空 m3u8 或 ts 加载失败时自动重试 - hls.on(Hls.Events.ERROR, (event, data) => { - if (data.fatal) { - switch (data.type) { - case Hls.ErrorTypes.NETWORK_ERROR: - hls.startLoad(); - ElMessage.error('网络错误, 请检查网络或重试'); - break; - case Hls.ErrorTypes.MEDIA_ERROR: - // 媒体解码错误 → 尝试恢复 - hls.recoverMediaError(); - break; - default: - // 其他致命错误 → 销毁,让下一次 initHls 重建 - hls.destroy(); - hlsInstance = null; - break; - } - } - }); - hlsInstance = hls; } else if (video.canPlayType('application/vnd.apple.mpegurl')) { // Safari/原生支持 HLS