From 3aea6f740bc239719341c6643f84378ece3e8508 Mon Sep 17 00:00:00 2001 From: lixuefeng <1126141216@qq.com> Date: Wed, 14 Jan 2026 00:58:18 +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 --- src/views/hotel/components/video-box.vue | 31 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/views/hotel/components/video-box.vue b/src/views/hotel/components/video-box.vue index ad3a576..8d35a0c 100644 --- a/src/views/hotel/components/video-box.vue +++ b/src/views/hotel/components/video-box.vue @@ -385,16 +385,27 @@ const handleItemVideo = (url, type, code,item) => { videoLog.value = 2 cameraIndexCode.value = code setTimeout(() => { - hlsRef = new Hls({ - maxBufferLength: 10, // 最大缓冲长度(秒) - maxMaxBufferLength: 15, // 缓冲区长度的上限 - maxBufferSize: 30 * 1000 * 1000 // 最大缓冲大小(字节) - }) - hlsRef.loadSource(url) - hlsRef.attachMedia(videoRef.value) - hlsRef.on(Hls.Events.MANIFEST_PARSED, () => { - videoRef.value.play() - }) + if (url.startsWith('http://192.168.77.200:8050/')) { + hlsRef = new WebRTCWhep({ + url: url, // WHEP 服务器地址 + container: videoRef.value, // 视频播放容器 + onError: (error) => { + console.error('播放错误:', error) + } + }) + } else { + hlsRef = new Hls({ + maxBufferLength: 10, // 最大缓冲长度(秒) + maxMaxBufferLength: 15, // 缓冲区长度的上限 + maxBufferSize: 30 * 1000 * 1000 // 最大缓冲大小(字节) + }) + hlsRef.loadSource(url) + hlsRef.attachMedia(videoRef.value) + hlsRef.on(Hls.Events.MANIFEST_PARSED, () => { + videoRef.value.play() + }) + } + if (type == 100) initVideo() }, 1000) }