From 13da8fc106d178af23a41de2ed2455348017f995 Mon Sep 17 00:00:00 2001 From: zjc <1034206993@qq.com> Date: Wed, 22 Jan 2025 18:45:58 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=A7=86=E9=A2=91=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=96=B0=E5=A2=9E=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/monitor/components/box-2.vue | 89 +++++++++++++++++--------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/src/views/monitor/components/box-2.vue b/src/views/monitor/components/box-2.vue index 2e51567..3d21007 100644 --- a/src/views/monitor/components/box-2.vue +++ b/src/views/monitor/components/box-2.vue @@ -40,7 +40,12 @@
-
+
{ // setInterval(() => { @@ -170,6 +181,7 @@ const handleNav = (e) => { if (current.value == e) return videoLog.value = 1 + params.pageNum = 1 videoList.value = [] current.value = e getVideoList() @@ -203,37 +215,44 @@ videoSrc.value = res.data.url } const getVideoList = async () => { - let res = await getVideoListApi({ - businessScenicArea: scenicSpotId.value, - businessVideoDisplayPosition: navList.value[current.value].dictValue - }) - videoList.value = res.data - // postVideoRemain() - nextTick(() => { - videoList.value.forEach(async (item, index) => { - const video = document.getElementById(`monitorVideo${index}`) + params.businessVideoDisplayPosition = navList.value[current.value].dictValue + let res = await getVideoListApi(params) + if (res.data.length > 0) { + let list = res.data + list.forEach(async (i) => { let res = await postRefreshApi({ type: 'hls', - businessVideoDisplayPosition: item.businessVideoDisplayPosition, - cameraIndexCode: item.cameraIndexCode + businessVideoDisplayPosition: i.businessVideoDisplayPosition, + cameraIndexCode: i.cameraIndexCode }) - item.hlsUrl = res.data.hlsUrl - const hls = new Hls({ - maxBufferLength: 10, // 最大缓冲长度(秒) - maxMaxBufferLength: 15, // 缓冲区长度的上限 - maxBufferSize: 30 * 1000 * 1000 // 最大缓冲大小(字节) - }) - hls.loadSource(res.data.hlsUrl) - hls.attachMedia(video) - hls.on(Hls.Events.MANIFEST_PARSED, () => { - video.play() + return { + ...i, + hlsUrl: res.data.hlsUrl + } + }) + videoList.value = [...videoList.value, ...res.data] + params.pageNum++ + // postVideoRemain() + nextTick(() => { + videoList.value.forEach(async (x, index) => { + const video = document.getElementById(`monitorVideo${index}`) + const hls = new Hls({ + maxBufferLength: 10, // 最大缓冲长度(秒) + maxMaxBufferLength: 15, // 缓冲区长度的上限 + maxBufferSize: 30 * 1000 * 1000 // 最大缓冲大小(字节) + }) + hls.loadSource(x.hlsUrl) + hls.attachMedia(video) + hls.on(Hls.Events.MANIFEST_PARSED, () => { + video.play() + }) }) }) - }) + } } const getVideoType = async (id) => { let res = await getVideoTypeApi({ - businessScenicArea: scenicSpotId.value + businessScenicArea: params.businessScenicArea }) if (res.data.length > 0) { navList.value = res.data @@ -244,15 +263,23 @@ } } const getVideoRegions = async () => { - let res = await getVideoRegionsApi({ - businessScenicArea: scenicSpotId.value - }) - regionList.value = res.data - console.log(regionList.value, 'regionList') + if (loading.value) return + loading.value = true + try { + let res = await getVideoRegionsApi({ + businessScenicArea: params.businessScenicArea + }) + regionList.value = res.data + loading.value = false + } catch (error) { + loading.value = false + } } const onMonitorChange = () => { monitorChange = PubSub.subscribe('monitorChange', (res, data) => { - scenicSpotId.value = data.scenicSpotId + params.businessScenicArea = data.scenicSpotId + params.pageNum = 1 + videoList.value = [] regionList.value = [] getVideoType() getVideoRegions()