diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 2ca3adf..d979925 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -5,6 +5,10 @@ "ComputedRef": true, "DirectiveBinding": true, "EffectScope": true, + "ElLoading": true, + "ElMessage": true, + "ElMessageBox": true, + "ElNotification": true, "ExtractDefaultPropTypes": true, "ExtractPropTypes": true, "ExtractPublicPropTypes": true, diff --git a/src/utils/video.ts b/src/utils/video.ts index 6380c60..2dce39b 100644 --- a/src/utils/video.ts +++ b/src/utils/video.ts @@ -26,6 +26,28 @@ export const initHls = (monitorVideoUrl, monitorVideoRef) => { video.play().catch(() => {}); } catch (e) {} }); + + // ★ 错误自动恢复:hls.js 拿到空 m3u8 或 ts 加载失败时自动重试 + hls.on(Hls.Events.ERROR, (event, data) => { + if (data.fatal) { + switch (data.type) { + case Hls.ErrorTypes.NETWORK_ERROR: + // 网络错误(m3u8 404 / ts 404)→ 重新开始加载 + hls.startLoad(); + 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