Lita-Tako месяцев назад: 4
Родитель
Сommit
4c206875b4
3 измененных файлов с 118 добавлено и 10 удалено
  1. 4 0
      src/api/previewPlayback/index.js
  2. 16 1
      src/components/video/Live.vue
  3. 98 9
      src/components/video/Replay.vue

+ 4 - 0
src/api/previewPlayback/index.js

@@ -9,3 +9,7 @@ export const getPreview = (query) => {
9 9
 export const controlling = (data) => {
10 10
 	return request('/controlling', data, 'get')
11 11
 }
12
+
13
+export const getPlayback = (data) => {
14
+	return request('/getPlayback', data, 'get')
15
+}

+ 16 - 1
src/components/video/Live.vue

@@ -180,9 +180,25 @@
180 180
 		)
181 181
 	}
182 182
 
183
+	const findCameraByCameraId = (cameraId) => {
184
+		for (const root of cameraListData.value) {
185
+			const list = root.children || []
186
+			for (const d of list) {
187
+				if (d.cameraId == cameraId) {
188
+					return d
189
+				}
190
+			}
191
+		}
192
+		return undefined
193
+	}
194
+
183 195
 	const doControl = (command, action = 0, speed = 50, presetIndex = 10) => {
184 196
 		if (videoMap[currentWindowIndex]) {
185 197
 			const data = videoMap[currentWindowIndex]
198
+			const c = findCameraByCameraId(cameraId)
199
+			if (c.cameraType !== '1') {
200
+				return message.warning('该操作必须是球形摄像机')
201
+			}
186 202
 			const cmd = {
187 203
 				action,
188 204
 				command,
@@ -282,7 +298,6 @@
282 298
 		getOrgData()
283 299
 		init()
284 300
 		createPlayer()
285
-		getPreview({ cameraIndexCode: '0' })
286 301
 	})
287 302
 </script>
288 303
 

+ 98 - 9
src/components/video/Replay.vue

@@ -1,5 +1,5 @@
1 1
 <script setup>
2
-	import { getPreview } from '@/api/previewPlayback'
2
+	import { getPlayback, getPreview } from '@/api/previewPlayback'
3 3
 	import { useRoute } from 'vue-router'
4 4
 	import commonSelect from '@/components/CommonSelector/index.vue'
5 5
 	import api from '@/api/orgInfo/info'
@@ -20,6 +20,7 @@
20 20
 	let videoMap = {}
21 21
 	let currentWindowIndex = 0
22 22
 	const mode = 0 // 0 普通模式  1 高级模式
23
+	const date = ref([])
23 24
 
24 25
 	const init = () => {
25 26
 		window.addEventListener('resize', () => {
@@ -171,11 +172,100 @@
171 172
 		})
172 173
 	}
173 174
 
175
+	const cameraSelect = (cameraId, event) => {
176
+		const camera = event.node
177
+		if (camera.root) return
178
+		console.log('选择摄像头', camera)
179
+		if (!date.value || date.value.length <= 0) {
180
+			return message.warning('请先选择日期')
181
+		}
182
+		const { cameraIndexCode } = camera
183
+		getPlaybackVideo({ cameraIndexCode }).then((resp) => {
184
+			const { url } = resp
185
+			if (url) {
186
+				const { startTime, endTime } = date.value
187
+				player.value.JS_Play(url, { playURL: url, mode }, 0, startTime, endTime).then(
188
+					() => {
189
+						console.log('playbackStart success')
190
+					},
191
+					(e) => {
192
+						console.error(e)
193
+					}
194
+				)
195
+			} else {
196
+				message.error('无法获取视频地址')
197
+			}
198
+		})
199
+	}
200
+
201
+	const getPlaybackVideo = ({ cameraIndexCode }) => {
202
+		const [beginTime, endTime] = date.value
203
+		return getPlayback({
204
+			beginTime,
205
+			endTime,
206
+			cameraIndexCode,
207
+			recordLocation: 1,
208
+			protocol: 'WSS'
209
+		})
210
+	}
211
+
212
+	const slow = () => {
213
+		player.value.JS_Slow().then(
214
+			(rate) => {
215
+				// this.playback.rate = rate
216
+			},
217
+			(e) => {
218
+				console.error(e)
219
+			}
220
+		)
221
+	}
222
+
223
+	const fast = () => {
224
+		player.value.JS_Fast().then(
225
+			(rate) => {
226
+				// this.playback.rate = rate
227
+			},
228
+			(e) => {
229
+				console.error(e)
230
+			}
231
+		)
232
+	}
233
+
234
+	const pause = () => {
235
+		player.value.JS_Pause().then(
236
+			() => {
237
+				console.log('playbackPause success')
238
+			},
239
+			(e) => {
240
+				console.error(e)
241
+			}
242
+		)
243
+	}
244
+
245
+	const resume = () => {
246
+		player.value.JS_Resume().then(
247
+			() => {
248
+				console.log('playbackResume success')
249
+			},
250
+			(e) => {
251
+				console.error(e)
252
+			}
253
+		)
254
+	}
255
+
256
+	const stop = () => {
257
+		player.value.JS_Stop().then(
258
+			() => {},
259
+			(e) => {
260
+				console.error(e)
261
+			}
262
+		)
263
+	}
264
+
174 265
 	onMounted(() => {
175 266
 		getOrgData()
176 267
 		init()
177 268
 		createPlayer()
178
-		getPreview({ cameraIndexCode: '0' })
179 269
 	})
180 270
 </script>
181 271
 
@@ -196,7 +286,7 @@
196 286
 		<div class="control w-[20%] h-full">
197 287
 			<a-tabs v-model:activeKey="activeKey">
198 288
 				<a-tab-pane key="1" tab="摄像头列表">
199
-					回放日期 <a-range-picker value-format="YYYY-MM-DD HH:mm:ss" show-time />
289
+					回放日期 <a-range-picker v-model:value="date" value-format="YYYY-MM-DDTHH:mm:ssZ" show-time />
200 290
 					<div class="mt-5">
201 291
 						<a-tree :tree-data="cameraListData" @select="cameraSelect" class="w-full">
202 292
 							<template #title="{ title, key }">
@@ -208,14 +298,13 @@
208 298
 				</a-tab-pane>
209 299
 				<a-tab-pane key="2" tab="操作" force-render>
210 300
 					<div class="row">
211
-						<a-button type="primary" class="mr-5 btn">&lt;&lt; 慢放</a-button>
212
-						<a-button type="primary" class="btn">快放 &gt;&gt;</a-button>
301
+						<a-button type="primary" class="mr-5 btn" @click="slow">&lt;&lt; 慢放</a-button>
302
+						<a-button type="primary" class="btn" @click="fast">快放 &gt;&gt;</a-button>
213 303
 					</div>
214 304
 					<div class="row">
215
-						<a-button type="primary" class="mr-1 w-[60px]">暂停</a-button>
216
-						<a-button type="primary" class="mr-1 w-[60px]">恢复</a-button>
217
-						<a-button type="primary" class="mr-1 w-[60px]">停止</a-button>
218
-						<a-button type="primary" class="w-[120px]">全部停止</a-button>
305
+						<a-button type="primary" class="mr-1 w-[60px]" @click="pause">暂停</a-button>
306
+						<a-button type="primary" class="mr-1 w-[60px]" @click="resume">恢复</a-button>
307
+						<a-button type="primary" class="mr-1 w-[60px]" @click="stop">停止</a-button>
219 308
 					</div>
220 309
 				</a-tab-pane>
221 310
 			</a-tabs>