@@ -4,6 +4,10 @@ import Calendar from 'vue3-slot-calendar'
4
4
import Video from ' @/components/Video.vue'
5
5
import { useRoute } from ' vue-router'
6
6
import { onMounted , onUnmounted , ref } from ' vue'
7
+ import IconLeft from ' @/components/icons/IconLeft.vue'
8
+ import IconTop from ' @/components/icons/IconTop.vue'
9
+ import IconRight from ' @/components/icons/IconRight.vue'
10
+ import IconDown from ' @/components/icons/IconDown.vue'
7
11
8
12
const route = useRoute ()
9
13
const filterDay = ref (new Date ())
@@ -13,6 +17,9 @@ const currentTime = ref(0)
13
17
const camera = ref ({})
14
18
const video = ref ()
15
19
const progress = ref ()
20
+ const live = ref (true )
21
+ const toLiveTab = ref ()
22
+ const toSeekTab = ref ()
16
23
17
24
onMounted (() => {
18
25
loadCamera ()
@@ -22,7 +29,7 @@ onMounted(() => {
22
29
})
23
30
24
31
onUnmounted (() => {
25
- window .removeEventListener (' keydown ' , shortcutKey)
32
+ window .removeEventListener (' key ref="moveLeft" down ' , shortcutKey)
26
33
})
27
34
28
35
const prepareVideo = () => {
@@ -52,7 +59,10 @@ async function requestVideo() {
52
59
selectDate .setHours (0 , 0 , 0 , 0 )
53
60
let pos = Math .floor (selectDate .getTime () / 1000 ) + Number (currentTime .value )
54
61
let src = ` ${ http .apiServer } /media/${ route .params .id } /live.ts`
55
- video .value .init (src, pos)
62
+ if (live .value ) {
63
+ pos = null
64
+ }
65
+ video .value .init (src, pos, live .value )
56
66
}
57
67
58
68
function formatTime (time ) {
@@ -64,7 +74,7 @@ function formatTime(time) {
64
74
65
75
function updateProgress (e ) {
66
76
let newTime = Number (lastPlayOffet .value ) + Math .floor (e .currentTime )
67
- if (camera .value .disableTimeUpdate ) {
77
+ if (camera .value && camera . value .disableTimeUpdate ) {
68
78
return
69
79
}
70
80
currentTime .value = newTime
@@ -115,6 +125,19 @@ function shortcutKey(e) {
115
125
return
116
126
}
117
127
}
128
+
129
+ const moveCamera = async (x , y ) => {
130
+ let session = JSON .parse (window .localStorage .getItem (' session' ))
131
+ let r = await http .post (` /v1/api/cameras/${ route .params .id } /move` , {
132
+ session: session,
133
+ body: {
134
+ x: x,
135
+ y: y,
136
+ },
137
+ })
138
+ console .log (r)
139
+ }
140
+
118
141
const showprogress = e => {
119
142
console .log (e, progress .value .getBoundingClientRect ().width )
120
143
camera .value .progress = formatTime (
@@ -127,6 +150,25 @@ const disableArrowKeys = event => {
127
150
event .preventDefault ()
128
151
}
129
152
}
153
+
154
+ const toLive = e => {
155
+ if (live .value ) {
156
+ return
157
+ }
158
+ toLiveTab .value .classList .add (' selected' )
159
+ toSeekTab .value .classList .remove (' selected' )
160
+ live .value = true
161
+ requestVideo ()
162
+ }
163
+ const toSeek = e => {
164
+ if (! live .value ) {
165
+ return
166
+ }
167
+ toLiveTab .value .classList .remove (' selected' )
168
+ toSeekTab .value .classList .add (' selected' )
169
+ live .value = false
170
+ requestVideo ()
171
+ }
130
172
</script >
131
173
132
174
<template >
@@ -135,7 +177,7 @@ const disableArrowKeys = event => {
135
177
<div class =" video" >
136
178
<Video ref =" video" @timeupdate =" updateProgress" ></Video >
137
179
</div >
138
- <div class =" timeline" >
180
+ <div class =" timeline" v-if = " !live " >
139
181
<input
140
182
ref =" progress"
141
183
class =" progress"
@@ -171,7 +213,46 @@ const disableArrowKeys = event => {
171
213
{{ camera.meta ? camera.meta.model : 'loading' }}
172
214
</div >
173
215
</div >
216
+ <div class =" change-mode" >
217
+ <div class =" tab tab1 selected" @click =" toLive" ref =" toLiveTab" >
218
+ Live
219
+ </div >
220
+ <div class =" tab tab2" @click =" toSeek" ref =" toSeekTab" >Seek</div >
221
+ </div >
222
+ <div v-if =" live" class =" ptz" >
223
+ <div class =" btns" >
224
+ <div
225
+ class =" btn"
226
+ @click =" moveCamera(-0.1, 0)"
227
+ style =" left : 0 ; top : 60px "
228
+ >
229
+ <IconLeft />
230
+ </div >
231
+ <div
232
+ class =" btn"
233
+ @click =" moveCamera(0, 0.2)"
234
+ style =" left : 60px ; top : 0px "
235
+ >
236
+ <IconTop />
237
+ </div >
238
+ <div
239
+ class =" btn"
240
+ @click =" moveCamera(0.1, 0)"
241
+ style =" right : 0 ; top : 60px "
242
+ >
243
+ <IconRight />
244
+ </div >
245
+ <div
246
+ class =" btn"
247
+ @click =" moveCamera(0, -0.2)"
248
+ style =" right : 60px ; bottom : 0px "
249
+ >
250
+ <IconDown />
251
+ </div >
252
+ </div >
253
+ </div >
174
254
<Calendar
255
+ v-else
175
256
v-model =" filterDay"
176
257
:has-input =" false"
177
258
@day-click =" selectDay"
@@ -229,6 +310,62 @@ const disableArrowKeys = event => {
229
310
font-size : 13px ;
230
311
color : darkslategray ;
231
312
}
313
+ .change-mode {
314
+ display : flex ;
315
+ justify-content : center ;
316
+ align-items : center ;
317
+ height : 32px ;
318
+ line-height : 32px ;
319
+ margin-bottom : 10px ;
320
+ }
321
+ .change-mode .tab {
322
+ height : 32px ;
323
+ line-height : 32px ;
324
+ cursor : pointer ;
325
+ flex : 1 ;
326
+ text-align : center ;
327
+ background-color : #d1d9e0 ;
328
+ user-select : none ;
329
+ }
330
+ .change-mode .tab1 {
331
+ border-radius : 5px 0 0 5px ;
332
+ }
333
+ .change-mode .tab2 {
334
+ border-radius : 0 5px 5px 0 ;
335
+ }
336
+ .change-mode .selected {
337
+ background-color : #083f39 ;
338
+ color : #fff ;
339
+ }
340
+ .ptz {
341
+ width : 247px ;
342
+ display : flex ;
343
+ justify-content : center ;
344
+ }
345
+ .ptz .btns {
346
+ display : block ;
347
+ margin-top : 20px ;
348
+ width : 180px ;
349
+ height : 180px ;
350
+ position : absolute ;
351
+ }
352
+ .ptz .btns .btn {
353
+ display : flex ;
354
+ width : 60px ;
355
+ height : 60px ;
356
+ position : absolute ;
357
+ cursor : pointer ;
358
+ justify-content : center ;
359
+ align-items : center ;
360
+ user-select : none ;
361
+ }
362
+ .ptz .btns .btn :hover {
363
+ background-color : #d1d9e0 ;
364
+ }
365
+ .ptz .btns .btn svg {
366
+ width : 32px ;
367
+ height : 32px ;
368
+ }
232
369
@media screen and (max-width : 1024px ) {
233
370
.cameraContainer {
234
371
padding : 0px 0 0 0 ;
@@ -245,6 +382,9 @@ const disableArrowKeys = event => {
245
382
.operation {
246
383
margin-right : 10px ;
247
384
}
385
+ .ptz {
386
+ margin : 0 auto ;
387
+ }
248
388
}
249
389
</style >
250
390
0 commit comments