From 724dc4a5611953b11f4886c91d8b595c49827128 Mon Sep 17 00:00:00 2001 From: lixuefeng <1126141216@qq.com> Date: Tue, 3 Feb 2026 10:14:46 +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 | 9 +++++++-- src/layout/components/CoreVideo/index.vue | 13 +++++++++---- src/views/collect/components/video-box.vue | 9 +++++++-- src/views/hotel/components/video-box.vue | 15 ++++++++++++--- src/views/monitor/components/box-1.vue | 3 ++- src/views/monitor/components/box-2.vue | 9 ++++++--- src/views/scenic/components/box-1.vue | 3 ++- src/views/traffic/components/box-2.vue | 3 ++- 11 files changed, 55 insertions(+), 22 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 a74e0f8..9adc643 100644 --- a/src/components/HlsPlayer/index.vue +++ b/src/components/HlsPlayer/index.vue @@ -176,6 +176,9 @@ 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 f0f1206..497e1ec 100644 --- a/src/layout/components/CoreVideo/allList.vue +++ b/src/layout/components/CoreVideo/allList.vue @@ -81,7 +81,8 @@ import {getVideoListApi, getColletListApi, getPreviewUrlApi} from '@/api/home' console.log(item, 'iscollect') let res = await getPreviewUrlApi({ cameraIndexCode: item.cameraIndexCode, - type: 'hls' + type: 'hls', + subStream:0 }) src.value = res.data.url isCollect.value = item.isCollect @@ -125,7 +126,8 @@ import {getVideoListApi, getColletListApi, getPreviewUrlApi} from '@/api/home' 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/')){ @@ -140,6 +142,9 @@ const createPlayer = (cameraIndexCode,videoElement) => { 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 8e80e42..1dc63a7 100644 --- a/src/layout/components/CoreVideo/index.vue +++ b/src/layout/components/CoreVideo/index.vue @@ -66,7 +66,8 @@ let isCollect = ref(0) const handleItem = async (item) => { let res = await getPreviewUrlApi({ cameraIndexCode: item.cameraIndexCode, - type: 'hls' + type: 'hls', + subStream:0 }) src.value = res.data.url cameraIndexCode.value = item.cameraIndexCode @@ -87,7 +88,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 @@ -95,7 +97,8 @@ let isCollect = ref(0) const createPlayer = (cameraIndexCode,videoElement) => { getPreviewUrlApi({ type: 'hls', - cameraIndexCode: cameraIndexCode + cameraIndexCode: cameraIndexCode, + subStream:0 }).then(res=>{ const url = res.data.url; if(url.startsWith('http://192.168.77.200:8050/')){ @@ -105,11 +108,13 @@ let isCollect = ref(0) iceServers: [{ urls: 'turn:192.168.77.200:3478',username: 'ZLMediaKit',credential: 'ZLMediaKit'}] }) player.on('error', (error) => { - console.error('错误:', error.message, error.type) if(error.type ==='REQUEST_ERROR' || error.type ==='NOT_FOUND_ERROR'){ createPlayer(cameraIndexCode,videoElement); } }) + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) } else{ diff --git a/src/views/collect/components/video-box.vue b/src/views/collect/components/video-box.vue index 340bf02..4f6d670 100644 --- a/src/views/collect/components/video-box.vue +++ b/src/views/collect/components/video-box.vue @@ -224,7 +224,8 @@ show.value = true let res = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode:itemCode + cameraIndexCode:itemCode, + subStream:0 }) cameraIndexCode.value = itemCode; isCollect.value = resource.isCollect @@ -283,7 +284,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/')){ @@ -298,6 +300,9 @@ createPlayer(cameraIndexCode,videoElement); } }) + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) }else{ const player = new Hls({ diff --git a/src/views/hotel/components/video-box.vue b/src/views/hotel/components/video-box.vue index 75cd1c0..3701d76 100644 --- a/src/views/hotel/components/video-box.vue +++ b/src/views/hotel/components/video-box.vue @@ -304,7 +304,8 @@ show.value = true let res = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode:itemCode + cameraIndexCode:itemCode, + subStream:0 }) cameraIndexCode.value = itemCode; isCollect.value = resource.isCollect @@ -340,7 +341,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/')){ @@ -355,6 +357,9 @@ createPlayer(cameraIndexCode,videoElement); } }) + player.on('play:failed', (err) => { + createPlayer(cameraIndexCode,videoElement); + }) webrtcRefs.push(player) } else{ @@ -424,7 +429,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 @@ -447,6 +453,9 @@ 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-1.vue b/src/views/monitor/components/box-1.vue index 44dd300..0512b27 100644 --- a/src/views/monitor/components/box-1.vue +++ b/src/views/monitor/components/box-1.vue @@ -261,7 +261,8 @@ window.addEventListener("message", async(e) => { let {code,data} = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode:e.data.cameraIndexCode + cameraIndexCode:e.data.cameraIndexCode, + subStream:0 }) if(code===200){ src.value = data.url diff --git a/src/views/monitor/components/box-2.vue b/src/views/monitor/components/box-2.vue index aa8a2d0..777e2ef 100644 --- a/src/views/monitor/components/box-2.vue +++ b/src/views/monitor/components/box-2.vue @@ -366,7 +366,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 @@ -438,7 +439,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 @@ -501,7 +503,8 @@ watch( 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/')){ diff --git a/src/views/scenic/components/box-1.vue b/src/views/scenic/components/box-1.vue index 163a75d..66df286 100644 --- a/src/views/scenic/components/box-1.vue +++ b/src/views/scenic/components/box-1.vue @@ -174,7 +174,8 @@ import pubSub from 'pubsub-js' window.addEventListener("message", async(e) => { let {code,data} = await getPreviewUrlApi({ type: 'hls', - cameraIndexCode:e.data.cameraIndexCode + cameraIndexCode:e.data.cameraIndexCode, + subStream:0 }) if(code===200){ src.value = data.url diff --git a/src/views/traffic/components/box-2.vue b/src/views/traffic/components/box-2.vue index 0720568..5040cce 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