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) }