Browse Source

视频相关

Lita-Tako 4 months ago
parent
commit
788b97264b
1 changed files with 40 additions and 2 deletions
  1. 40 2
      src/components/video/Live.vue

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

@@ -23,11 +23,39 @@
23
 	let currentWindowIndex = 0
23
 	let currentWindowIndex = 0
24
 	const mode = 0 // 0 普通模式  1 高级模式
24
 	const mode = 0 // 0 普通模式  1 高级模式
25
 	const isActive = ref(false)
25
 	const isActive = ref(false)
26
+	const tract = {}
27
+	let currentCameraList = []
28
+	let timer = null
26
 
29
 
27
 	const init = () => {
30
 	const init = () => {
28
 		window.addEventListener('resize', () => {
31
 		window.addEventListener('resize', () => {
29
 			if (player.vlaue) player.value.JS_Resize()
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
 	const getOrgData = () => {
61
 	const getOrgData = () => {
@@ -234,11 +262,14 @@
234
 	}
262
 	}
235
 
263
 
236
 	const startTrack = () => {
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
 	const stopTrack = () => {
271
 	const stopTrack = () => {
241
-		doControl('STOP_TRACK', 1)
272
+		delete tract[currentWindowIndex]
242
 	}
273
 	}
243
 
274
 
244
 	const captureOne = (i = null) => {
275
 	const captureOne = (i = null) => {
@@ -271,6 +302,7 @@
271
 		cameraApi.getNVRVideo({ orgId: org.orgId }).then((resp) => {
302
 		cameraApi.getNVRVideo({ orgId: org.orgId }).then((resp) => {
272
 			console.log('摄像头列表', resp)
303
 			console.log('摄像头列表', resp)
273
 			const list = resp || []
304
 			const list = resp || []
305
+			currentCameraList = list
274
 			const tree = [
306
 			const tree = [
275
 				{
307
 				{
276
 					root: true,
308
 					root: true,
@@ -344,6 +376,12 @@
344
 		init()
376
 		init()
345
 		createPlayer()
377
 		createPlayer()
346
 	})
378
 	})
379
+
380
+	onUnmounted(() => {
381
+		if (timer) {
382
+			clearInterval(timer)
383
+		}
384
+	})
347
 </script>
385
 </script>
348
 
386
 
349
 <template>
387
 <template>