From 5301a74ec99f9bf20e8cbd9f50dcdd00167a2301 Mon Sep 17 00:00:00 2001 From: lixuefeng <1126141216@qq.com> Date: Tue, 3 Feb 2026 10:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B1=BB=E5=9E=8B=EF=BC=9A=E5=BC=80=E5=8F=91?= =?UTF-8?q?=20=E6=8F=8F=E8=BF=B0=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 8 ++++---- package.json | 2 +- src/components/HlsPlayer/index.vue | 3 +++ src/layout/components/CoreVideo/allList.vue | 6 +++++- src/layout/components/CoreVideo/index.vue | 3 ++- src/views/collect/components/video-box.vue | 9 +++++++-- src/views/hotel/components/video-box.vue | 16 ++++++++++++---- src/views/monitor/components/box-2.vue | 15 ++++++++++++--- src/views/traffic/components/box-2.vue | 3 ++- 9 files changed, 48 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 834dfb8..fba883e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "vue-router": "^4.4.5", "vue3-seamless-scroll": "^2.0.1", "vuedraggable": "^4.1.0", - "whepts": "^1.1.11" + "whepts": "^1.1.12" }, "devDependencies": { "@vitejs/plugin-vue": "^5.2.1", @@ -6188,9 +6188,9 @@ "license": "MIT" }, "node_modules/whepts": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/whepts/-/whepts-1.1.11.tgz", - "integrity": "sha512-NJ37rUXS4aeO36sxmSTxMZTGXdScedxdhAt7oKhFhzAeV/IjNCWdyu8d+fSGSEAPjJS4FnBzwSFLrENZjAqcRA==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/whepts/-/whepts-1.1.12.tgz", + "integrity": "sha512-KllGslriMAhD6BDBbG6X653M8XgeYqxnjuEyaB7U/1nIZN6NoAGSWP3Av46g690r2UaaI69bNzfPn4efJBd+kA==", "license": "MIT", "dependencies": { "eventemitter3": "^5.0.4", diff --git a/package.json b/package.json index 83ac73f..ae1ab1f 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "vue-router": "^4.4.5", "vue3-seamless-scroll": "^2.0.1", "vuedraggable": "^4.1.0", - "whepts": "^1.1.11" + "whepts": "^1.1.12" }, "devDependencies": { "@vitejs/plugin-vue": "^5.2.1", diff --git a/src/components/HlsPlayer/index.vue b/src/components/HlsPlayer/index.vue index 6229011..fb49f28 100644 --- a/src/components/HlsPlayer/index.vue +++ b/src/components/HlsPlayer/index.vue @@ -176,6 +176,9 @@ export default { this.initializePlayer(); } }) + this.hls.on('play:failed', (err) => { + this.initializePlayer(); + }) }else{ this.hls = new Hls({ // 内存优化配置 diff --git a/src/layout/components/CoreVideo/allList.vue b/src/layout/components/CoreVideo/allList.vue index 8e6ba82..a04df88 100644 --- a/src/layout/components/CoreVideo/allList.vue +++ b/src/layout/components/CoreVideo/allList.vue @@ -122,7 +122,8 @@ const createPlayer = (cameraIndexCode,videoElement) => { getPreviewUrlApi({ type: 'hls', - cameraIndexCode: cameraIndexCode + cameraIndexCode: cameraIndexCode, + subStream:1 }).then(res=>{ const url = res.data.url; if(url.startsWith('http://192.168.77.200:8050/')){ @@ -137,6 +138,9 @@ createPlayer(cameraIndexCode,videoElement); } }) + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) } else{ diff --git a/src/layout/components/CoreVideo/index.vue b/src/layout/components/CoreVideo/index.vue index a8f8b56..c402fd1 100644 --- a/src/layout/components/CoreVideo/index.vue +++ b/src/layout/components/CoreVideo/index.vue @@ -92,7 +92,8 @@ let isCollect = ref(0) const getPreviewUrl = async (code) => { let res = await getPreviewUrlApi({ cameraIndexCode: code, - type: 'hls' + type: 'hls', + subStream:1 }) src.value = res.data.url videoShow.value = true diff --git a/src/views/collect/components/video-box.vue b/src/views/collect/components/video-box.vue index e184fb9..6a44e06 100644 --- a/src/views/collect/components/video-box.vue +++ b/src/views/collect/components/video-box.vue @@ -246,7 +246,8 @@ const handleCamera = async (itemCode,resource,index) => { show.value = true let res = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode:itemCode + cameraIndexCode:itemCode, + sub_stream: 0 }) cameraIndexCode.value = itemCode; isCollect.value = resource.isCollect @@ -297,7 +298,8 @@ const handleItemVideo = (url, type, code,item) => { const createPlayer = (cameraIndexCode,videoElement) => { getPreviewUrlApi({ type: 'hls', - cameraIndexCode: cameraIndexCode + cameraIndexCode: cameraIndexCode, + subStream:1 }).then(res=>{ const url = res.data.url; if(url.startsWith('http://192.168.77.200:8050/')){ @@ -312,6 +314,9 @@ const createPlayer = (cameraIndexCode,videoElement) => { createPlayer(cameraIndexCode,videoElement); } }) + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) } else{ diff --git a/src/views/hotel/components/video-box.vue b/src/views/hotel/components/video-box.vue index b73ec9b..e1ce01a 100644 --- a/src/views/hotel/components/video-box.vue +++ b/src/views/hotel/components/video-box.vue @@ -303,7 +303,8 @@ const handleCamera = async (itemCode,resource) => { show.value = true let res = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode:itemCode + cameraIndexCode:itemCode, + subStream:0 }) cameraIndexCode.value = itemCode; isCollect.value = resource.isCollect @@ -339,7 +340,8 @@ const currentChange = (e) => { const createPlayer = (cameraIndexCode,videoElement) => { getPreviewUrlApi({ type: 'hls', - cameraIndexCode: cameraIndexCode + cameraIndexCode: cameraIndexCode, + subStream:1 }).then(res=>{ const url = res.data.url; if(url.startsWith('http://192.168.77.200:8050/')){ @@ -354,7 +356,9 @@ const createPlayer = (cameraIndexCode,videoElement) => { createPlayer(cameraIndexCode,videoElement); } }) - + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) } else{ @@ -424,7 +428,8 @@ let thisVideo = ref(null) const handleItemVideo = async (url, type, code, item) => { let res = await getPreviewUrlApi({ cameraIndexCode: code, - type: 'hls' + type: 'hls', + subStream:0 }) url = res.data.url thisVideo.value = item @@ -447,6 +452,9 @@ const handleItemVideo = async (url, type, code, item) => { handleItemVideo(url, type, code, item); } }) + hlsRef.on('play:failed', (err) => { + handleItemVideo(url, type, code, item); + }) } else { hlsRef = new Hls({ maxBufferLength: 10, // 最大缓冲长度(秒) diff --git a/src/views/monitor/components/box-2.vue b/src/views/monitor/components/box-2.vue index 469ab50..410a8d1 100644 --- a/src/views/monitor/components/box-2.vue +++ b/src/views/monitor/components/box-2.vue @@ -258,7 +258,8 @@ const createPlayer = (cameraIndexCode,videoElement) => { getPreviewUrlApi({ type: 'hls', - cameraIndexCode: cameraIndexCode + cameraIndexCode: cameraIndexCode, + subStream:1 }).then(res=>{ const url = res.data.url; if(url.startsWith('http://192.168.77.200:8050/')){ @@ -273,6 +274,9 @@ createPlayer(cameraIndexCode,videoElement); } }) + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) } else{ @@ -393,7 +397,8 @@ const handleItemVideo = async (url, type, code, item) => { let res = await getPreviewUrlApi({ cameraIndexCode: code, - type: 'hls' + type: 'hls', + subStream:0 }) url = res.data.url thisVideo.value = item @@ -416,6 +421,9 @@ handleItemVideo(url, type, code, item); } }) + hlsRef.on('play:failed', (err) => { + handleItemVideo(url, type, code, item); + }) } else { hlsRef = new Hls({ maxBufferLength: 10, // 最大缓冲长度(秒) @@ -463,7 +471,8 @@ show.value = true let res = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode: itemCode + cameraIndexCode: itemCode, + subStream: 0 }) cameraIndexCode.value = itemCode; isCollect.value = resource.isCollect diff --git a/src/views/traffic/components/box-2.vue b/src/views/traffic/components/box-2.vue index cdd5cd7..145cf65 100644 --- a/src/views/traffic/components/box-2.vue +++ b/src/views/traffic/components/box-2.vue @@ -191,7 +191,8 @@ const getPreviewUrl = async (code) => { let res = await getPreviewUrlApi({ cameraIndexCode: code, - type: 'hls' + type: 'hls', + subStream:0 }) src.value = res.data.url videoShow.value = true