diff --git a/src/components/HlsPlayer/index.vue b/src/components/HlsPlayer/index.vue index be8f30f..2bf919a 100644 --- a/src/components/HlsPlayer/index.vue +++ b/src/components/HlsPlayer/index.vue @@ -177,6 +177,7 @@ // 错误处理和重连机制 player.on('error', (err) => { + player.unload() // 3 秒后尝试重新加载 setTimeout(() => { player.load() diff --git a/src/layout/components/CoreVideo/allList.vue b/src/layout/components/CoreVideo/allList.vue index 2ad909a..1d56c92 100644 --- a/src/layout/components/CoreVideo/allList.vue +++ b/src/layout/components/CoreVideo/allList.vue @@ -134,11 +134,12 @@ const createPlayer = (cameraIndexCode,videoElement) => { // 错误处理和重连机制 player.on(mpegtsjs.Events.ERROR, (err) => { player.unload(); + player.destroy(); console.error('播放器错误:', err) // 3 秒后尝试重新加载 setTimeout(() => { - player.load() - player.play() + console.error('重新加载【'+cameraIndexCode+'】' ) + createPlayer(cameraIndexCode,videoElement); }, 3000) }) diff --git a/src/layout/components/CoreVideo/index.vue b/src/layout/components/CoreVideo/index.vue index 07fa3c5..ce7a1ea 100644 --- a/src/layout/components/CoreVideo/index.vue +++ b/src/layout/components/CoreVideo/index.vue @@ -110,11 +110,12 @@ let isCollect = ref(0) // 错误处理和重连机制 player.on(mpegtsjs.Events.ERROR, (err) => { player.unload(); + player.destroy(); console.error('播放器错误:', err) // 3 秒后尝试重新加载 setTimeout(() => { - player.load() - player.play() + console.error('重新加载【'+cameraIndexCode+'】' ) + createPlayer(cameraIndexCode,videoElement); }, 3000) }) diff --git a/src/utils/config.js b/src/utils/config.js index 50bf75e..de654e1 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -7,6 +7,6 @@ export const proSocketBaseUrl = 'ws://192.168.77.200:8060' export const mode = 'pro' // 测试 dev 正式 pro export const devToken = - 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImE1OWFmNWYwLTU3OWItNDJkNy1hZDJhLTY0Y2JlODA5ZWI1NiJ9.BTxvu6jUWbN0qONWf5K6VzXopE8T8qXzKuX-mij21VJT4U0LdgnqToyqeNDQ2OyJ6cvpdJBzQ9mEEb-dnwrTpQ' + 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImE1OWFmNWYwLTU3OWItNDJkNy1hZDJhLTY0Y2JlODA5ZWI1NiJ9.BTxvu6jUWbN0qONWf5K6VzXopE8T8qXzKuX-mij21VJT4U0LdgnqToyqeNDQ2OyJ6cvpdJBzQ9mEEb-dnwrTpQ11' export const proToken = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImE1OWFmNWYwLTU3OWItNDJkNy1hZDJhLTY0Y2JlODA5ZWI1NiJ9.dSLZekRsYf5ZZDCYqFEOgHTi4GeHD0m10gGHXrbgpc-hD52Zt7Vw05cxhQ-lzY29yf2IxH0oYi28DBfHdtf9SA' diff --git a/src/views/collect/components/video-box.vue b/src/views/collect/components/video-box.vue index 260b48c..1be8c1c 100644 --- a/src/views/collect/components/video-box.vue +++ b/src/views/collect/components/video-box.vue @@ -284,11 +284,12 @@ // 错误处理和重连机制 player.on(mpegtsjs.Events.ERROR, (err) => { player.unload(); + player.destroy(); console.error('播放器错误:', err) // 3 秒后尝试重新加载 setTimeout(() => { - player.load() - player.play() + console.error('重新加载【'+cameraIndexCode+'】' ) + createPlayer(cameraIndexCode,videoElement); }, 3000) }) diff --git a/src/views/hotel/components/video-box.vue b/src/views/hotel/components/video-box.vue index ffe8515..bac866b 100644 --- a/src/views/hotel/components/video-box.vue +++ b/src/views/hotel/components/video-box.vue @@ -338,11 +338,12 @@ // 错误处理和重连机制 player.on(mpegtsjs.Events.ERROR, (err) => { player.unload(); + player.destroy(); console.error('播放器错误:', err) // 3 秒后尝试重新加载 setTimeout(() => { - player.load() - player.play() + console.error('重新加载【'+cameraIndexCode+'】' ) + createPlayer(cameraIndexCode,videoElement); }, 3000) }) diff --git a/src/views/monitor/components/box-2.vue b/src/views/monitor/components/box-2.vue index 68deba7..4d6df93 100644 --- a/src/views/monitor/components/box-2.vue +++ b/src/views/monitor/components/box-2.vue @@ -273,7 +273,6 @@ const postVideoRemain = async () => { // }) // }, 2000) } - const initVideo = () => { clearHlsRefs() nextTick(() => { @@ -284,7 +283,6 @@ const initVideo = () => { }) } const onInput = debounce((e) => { - if (e) { getVideoRegions('search') } else { @@ -370,9 +368,11 @@ const handleItemVideo = async (url, type, code, item) => { console.error('播放器错误:', err) // 3 秒后尝试重新加载 hlsRef.unload() + hlsRef.destroy() + // 3 秒后尝试重新加载 setTimeout(() => { - hlsRef.load() - hlsRef.play() + console.error('重新加载【'+cameraIndexCode+'】' ) + handleItemVideo(url, 101, code, item); }, 3000) }) } else { @@ -491,15 +491,19 @@ const createPlayer = (cameraIndexCode,videoElement) => { player.play() // 错误处理和重连机制 player.on(mpegtsjs.Events.ERROR, (err) => { + console.error('播放器错误【'+cameraIndexCode+'】:', err) player.unload(); - console.error('播放器错误:', err) + player.destroy(); // 3 秒后尝试重新加载 setTimeout(() => { - player.load() - player.play() + console.error('重新加载【'+cameraIndexCode+'】' ) + createPlayer(cameraIndexCode,videoElement); }, 3000) - }) + }) + player.on(mpegtsjs.Events.LOADING_COMPLETE, (err) => { + console.error('加载完成:', err) + }) hlsRefs.push(player) } else{