Lita-Tako пре 4 месеци
родитељ
комит
788b97264b
1 измењених фајлова са 40 додато и 2 уклоњено
  1. 40 2
      src/components/video/Live.vue

+ 40 - 2
src/components/video/Live.vue

@@ -23,11 +23,39 @@
23 23
 	let currentWindowIndex = 0
24 24
 	const mode = 0 // 0 普通模式  1 高级模式
25 25
 	const isActive = ref(false)
26
+	const tract = {}
27
+	let currentCameraList = []
28
+	let timer = null
26 29
 
27 30
 	const init = () => {
28 31
 		window.addEventListener('resize', () => {
29 32
 			if (player.vlaue) player.value.JS_Resize()
30 33
 		})
34
+		timer = setInterval(() => {
35
+			nextCameraPlay()
36
+		}, 15000)
37
+	}
38
+
39
+	const nextCameraPlay = () => {
40
+		for (let i of Object.keys(tract)) {
41
+			const arr = tract[i]
42
+			if (arr.length <= 0) continue
43
+			for (const c of arr) {
44
+				const { cameraIndexCode } = c
45
+				if (!cameraIndexCode) continue
46
+				getPreview({ cameraIndexCode, protocol: 'WS' }).then((resp) => {
47
+					if (!resp || !resp.url) return
48
+					const url = resp.url
49
+					play(i, url)
50
+						.then((_) => {
51
+							console.log(`窗口 ${i} 轮巡播放成功`)
52
+						})
53
+						.catch((err) => {
54
+							console.log(`窗口 ${i} 轮巡播放失败 ${resp}`)
55
+						})
56
+				})
57
+			}
58
+		}
31 59
 	}
32 60
 
33 61
 	const getOrgData = () => {
@@ -234,11 +262,14 @@
234 262
 	}
235 263
 
236 264
 	const startTrack = () => {
237
-		doControl('START_TRACK', 0)
265
+		if (currentCameraList.length <= 0) {
266
+			return message.warn('当前库区没有摄像头')
267
+		}
268
+		tract[currentWindowIndex] = [...currentCameraList]
238 269
 	}
239 270
 
240 271
 	const stopTrack = () => {
241
-		doControl('STOP_TRACK', 1)
272
+		delete tract[currentWindowIndex]
242 273
 	}
243 274
 
244 275
 	const captureOne = (i = null) => {
@@ -271,6 +302,7 @@
271 302
 		cameraApi.getNVRVideo({ orgId: org.orgId }).then((resp) => {
272 303
 			console.log('摄像头列表', resp)
273 304
 			const list = resp || []
305
+			currentCameraList = list
274 306
 			const tree = [
275 307
 				{
276 308
 					root: true,
@@ -344,6 +376,12 @@
344 376
 		init()
345 377
 		createPlayer()
346 378
 	})
379
+
380
+	onUnmounted(() => {
381
+		if (timer) {
382
+			clearInterval(timer)
383
+		}
384
+	})
347 385
 </script>
348 386
 
349 387
 <template>