Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-skynet-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-skynet-admin
Commits
4a57014d
Commit
4a57014d
authored
Sep 22, 2021
by
朱松文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态跟踪优化
parent
a20dd55b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
43 deletions
+91
-43
myVideo.scss
src/assets/scss/myVideo.scss
+0
-2
index.vue
src/components/DogInfo/index.vue
+0
-1
index.vue
src/components/MyVideo/index.vue
+29
-9
index.ts
src/components/MyVideo/track/index.ts
+41
-26
cameraData.ts
src/mock/cameraData.ts
+12
-3
index.vue
src/views/dashboard/index.vue
+9
-2
No files found.
src/assets/scss/myVideo.scss
View file @
4a57014d
...
@@ -2,7 +2,5 @@
...
@@ -2,7 +2,5 @@
position
:
absolute
;
position
:
absolute
;
top
:
30px
;
top
:
30px
;
left
:
60px
;
left
:
60px
;
width
:
30px
;
height
:
80px
;
border
:
1px
solid
red
;
border
:
1px
solid
red
;
}
}
\ No newline at end of file
src/components/DogInfo/index.vue
View file @
4a57014d
...
@@ -81,7 +81,6 @@ export default class DogInfo extends BaseVue {
...
@@ -81,7 +81,6 @@ export default class DogInfo extends BaseVue {
@
Prop
()
private
dog
:
DogData
;
@
Prop
()
private
dog
:
DogData
;
play
():
void
{
play
():
void
{
console
.
log
(
"
aaa
"
,
this
.
dog
);
this
.
$emit
(
"
play
"
,
this
.
dog
);
this
.
$emit
(
"
play
"
,
this
.
dog
);
}
}
}
}
...
...
src/components/MyVideo/index.vue
View file @
4a57014d
<
template
>
<
template
>
<video
id=
"najiu-player"
class=
"video-js"
muted
preload=
"auto"
>
<video
id=
"najiu-player"
class=
"video-js"
muted
preload=
"auto"
>
<source
:src=
"videoUrl"
type=
"video/mp4"
/>
<source
ref=
"videoSource"
:src=
"videoUrl"
type=
"video/mp4"
/>
<p
class=
"vjs-no-js"
>
当前浏览器不支持视频播放
</p>
<p
class=
"vjs-no-js"
>
当前浏览器不支持视频播放
</p>
</video>
</video>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
"
vue-property-decorator
"
;
import
{
Component
,
Vue
,
Prop
}
from
"
vue-property-decorator
"
;
import
"
video.js/dist/video-js.min.css
"
;
import
"
video.js/dist/video-js.min.css
"
;
import
videojs
from
"
video.js
"
;
import
videojs
from
"
video.js
"
;
import
"
@/components/MyVideo/track/index
"
;
import
"
@/components/MyVideo/track/index
"
;
...
@@ -33,11 +33,30 @@ export default class MyVideo extends Vue {
...
@@ -33,11 +33,30 @@ export default class MyVideo extends Vue {
controls
:
true
,
controls
:
true
,
autoplay
:
true
,
autoplay
:
true
,
width
:
this
.
width
,
width
:
this
.
width
,
controlBar
:
{
children
:
[
{
name
:
"
playToggle
"
},
{
name
:
"
volumePanel
"
},
{
name
:
"
currentTimeDisplay
"
},
{
name
:
"
timeDivider
"
},
{
name
:
"
progressControl
"
},
{
name
:
"
liveDisplay
"
},
{
name
:
"
durationDisplay
"
},
{
name
:
"
seekToLive
"
},
{
name
:
"
remainingTimeDisplay
"
},
{
name
:
"
customControlSpacer
"
},
{
name
:
"
playbackRateMenuButton
"
},
{
name
:
"
chaptersButton
"
},
{
name
:
"
descriptionsButton
"
},
{
name
:
"
subsCapsButton
"
},
{
name
:
"
audioTrackButton
"
},
{
name
:
"
fullscreenToggle
"
},
],
},
},
},
function
onPlayerReady
()
{
function
onPlayerReady
()
{
//@ts-ignore
//@ts-ignore
this
.
addChild
(
"
DogTrack
"
);
this
.
addChild
(
"
DogTrack
"
);
console
.
log
(
"
**
"
,
_this
.
trackData
);
_this
.
dogTrack
=
this
.
getChild
(
"
DogTrack
"
);
_this
.
dogTrack
=
this
.
getChild
(
"
DogTrack
"
);
_this
.
dogTrack
.
initData
(
_this
.
trackData
);
_this
.
dogTrack
.
initData
(
_this
.
trackData
);
this
.
play
();
this
.
play
();
...
@@ -48,12 +67,13 @@ export default class MyVideo extends Vue {
...
@@ -48,12 +67,13 @@ export default class MyVideo extends Vue {
this
.
$emit
(
"
play
"
);
this
.
$emit
(
"
play
"
);
}
}
@
Watch
(
"
src
"
)
onSrcChange
(
videoSrc
:
string
,
trackData
:
TrackData
[])
{
onSrcChange
(
newValue
:
string
,
oldValue
:
string
)
{
this
.
dogTrack
.
initData
(
trackData
);
if
(
oldValue
===
newValue
)
return
;
this
.
videoUrl
=
videoSrc
;
this
.
dogTrack
.
initData
(
this
.
trackData
);
//@ts-ignore
this
.
videoUrl
=
newValue
;
this
.
$refs
[
"
videoSource
"
].
src
=
videoSrc
;
this
.
player
.
src
(
newValue
);
console
.
log
(
"
aaa
"
,
this
.
$refs
[
"
videoSource
"
]);
this
.
player
.
src
(
videoSrc
);
this
.
player
.
play
();
this
.
player
.
play
();
}
}
...
...
src/components/MyVideo/track/index.ts
View file @
4a57014d
...
@@ -4,17 +4,26 @@ import { TrackData } from "../data"
...
@@ -4,17 +4,26 @@ import { TrackData } from "../data"
const
Component
=
videojs
.
getComponent
(
'
Component
'
);
const
Component
=
videojs
.
getComponent
(
'
Component
'
);
class
DogTrack
extends
Component
{
class
DogTrack
extends
Component
{
trackData
=
[]
//传入初始数组
processing
=
false
//是否在处理中
myel
=
undefined
defaultWidth
=
0
defaultHeight
=
0
defaultElWidth
=
""
defaultElHeight
=
""
constructor
(
player
,
options
)
{
constructor
(
player
,
options
)
{
super
(
player
,
options
);
super
(
player
,
options
);
const
this_
=
this
//player 默认宽高
this
.
defaultWidth
=
player
.
el_
.
offsetWidth
this
.
defaultHeight
=
player
.
el_
.
offsetHeight
player
.
on
(
"
timeupdate
"
,
(
e
)
=>
this
.
update
(
e
))
player
.
on
(
"
timeupdate
"
,
(
e
)
=>
this
.
update
(
e
))
player
.
on
(
"
fullscreenchange
"
,
(
e
)
=>
this
.
fullScreenChange
.
call
(
this_
,
e
,
player
))
}
}
trackData
=
[]
//传入初始数组
trackingData
=
[]
//正在跟踪的数组
trackedData
=
[]
//已经被跟踪过的数组
processing
=
false
//是否在处理中
myel
=
undefined
createEl
():
HTMLDivElement
{
createEl
():
HTMLDivElement
{
const
el
=
document
.
createElement
(
"
div
"
)
const
el
=
document
.
createElement
(
"
div
"
)
...
@@ -23,16 +32,25 @@ class DogTrack extends Component {
...
@@ -23,16 +32,25 @@ class DogTrack extends Component {
return
el
;
return
el
;
}
}
fullScreenChange
(
e
,
player
)
{
if
(
player
.
isFullscreen
())
{
this
.
myel
.
style
.
width
=
`
${
this
.
myel
.
offsetWidth
*
(
e
.
currentTarget
.
offsetWidth
/
this
.
defaultWidth
)}
px`
this
.
myel
.
style
.
height
=
`
${
this
.
myel
.
offsetHeight
*
(
e
.
currentTarget
.
offsetHeight
/
this
.
defaultHeight
)}
px`
}
else
{
this
.
myel
.
style
.
width
=
this
.
defaultElWidth
this
.
myel
.
style
.
height
=
this
.
defaultElHeight
}
}
update
(
e
)
{
update
(
e
)
{
if
(
this
.
processing
||
this
.
track
ing
Data
.
length
===
0
||
!
this
.
myel
)
return
if
(
this
.
processing
||
this
.
trackData
.
length
===
0
||
!
this
.
myel
)
return
this
.
processing
=
true
this
.
processing
=
true
const
currentTime
=
this
.
player_
.
currentTime
()
*
1000
const
currentTime
=
this
.
player_
.
currentTime
()
*
1000
for
(
let
i
=
0
;
i
<
this
.
track
ing
Data
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
trackData
.
length
;
i
++
)
{
const
d
=
this
.
track
ing
Data
[
i
]
const
d
=
this
.
trackData
[
i
]
if
(
currentTime
>
d
.
beginTime
&&
currentTime
<
d
.
endTime
)
{
if
(
currentTime
>
d
.
beginTime
&&
currentTime
<
d
.
endTime
)
{
this
.
myel
.
style
.
top
=
`
${
d
.
position
.
top
}
%`
this
.
myel
.
style
.
top
=
`
${
d
.
position
.
top
}
%`
this
.
myel
.
style
.
left
=
`
${
d
.
position
.
left
}
%`
this
.
myel
.
style
.
left
=
`
${
d
.
position
.
left
}
%`
this
.
trackedData
.
push
(...
this
.
trackingData
.
splice
(
0
,
i
+
1
))
break
;
break
;
}
}
}
}
...
@@ -40,26 +58,23 @@ class DogTrack extends Component {
...
@@ -40,26 +58,23 @@ class DogTrack extends Component {
}
}
initData
(
data
:
TrackData
[])
{
initData
(
data
:
TrackData
[])
{
this
.
trackData
.
length
=
0
if
(
!
data
||
data
.
length
===
0
)
return
;
this
.
myel
=
document
.
getElementById
(
"
trackDiv
"
)
this
.
myel
=
document
.
getElementById
(
"
trackDiv
"
)
if
(
!
data
||
data
.
length
===
0
)
{
this
.
myel
.
style
.
width
=
`
${
data
[
0
].
shape
.
width
}
px`
this
.
trackData
=
[]
this
.
myel
.
style
.
height
=
`
${
data
[
0
].
shape
.
height
}
px`
return
this
.
defaultElHeight
=
this
.
myel
.
style
.
height
}
this
.
defaultElWidth
=
this
.
myel
.
style
.
width
let
pre
;
this
.
trackData
=
data
.
map
((
d
:
TrackData
)
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
!
pre
)
{
const
d
=
data
[
i
]
d
.
beginTime
=
0
;
if
(
i
===
data
.
length
-
1
)
{
d
.
endTime
=
d
.
time
;
this
.
trackData
.
push
({
...
d
,
beginTime
:
d
.
time
,
endTime
:
Number
.
MAX_SAFE_INTEGER
})
}
else
{
}
else
{
d
.
beginTime
=
pre
.
endTime
;
this
.
trackData
.
push
({
...
d
,
beginTime
:
d
.
time
,
endTime
:
data
[
i
+
1
].
time
})
d
.
endTime
=
d
.
time
}
}
pre
=
d
}
this
.
trackingData
.
push
(
d
)
console
.
log
(
"
data
"
,
this
.
trackData
)
return
d
})
console
.
log
(
"
data
"
,
this
.
trackData
,
this
.
trackingData
)
}
}
...
...
src/mock/cameraData.ts
View file @
4a57014d
...
@@ -35,14 +35,17 @@ export default {
...
@@ -35,14 +35,17 @@ export default {
hairColor
:
"
黑白相间
"
,
hairColor
:
"
黑白相间
"
,
picture
:
picture
:
"
http://10.2.100.131/tianwang/images/%E8%A7%86%E9%A2%91%E7%BB%93%E6%9E%84%E5%8C%96/u283.png
"
,
"
http://10.2.100.131/tianwang/images/%E8%A7%86%E9%A2%91%E7%BB%93%E6%9E%84%E5%8C%96/u283.png
"
,
videoUrl
:
"
http://skynet-test.inajiu.com:7011/sn-web/video/video
"
,
videoUrl
:
"
http://skynet-test.inajiu.com:7011/sn-web/video/video
?a=abc.mp4
"
,
trackData
:
[
trackData
:
[
{
time
:
0
,
position
:
{
top
:
0
,
left
:
0
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
500
,
position
:
{
top
:
15
,
left
:
15
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
500
,
position
:
{
top
:
15
,
left
:
15
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1000
,
position
:
{
top
:
20
,
left
:
20
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1000
,
position
:
{
top
:
20
,
left
:
20
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1500
,
position
:
{
top
:
25
,
left
:
25
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1500
,
position
:
{
top
:
25
,
left
:
25
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2000
,
position
:
{
top
:
30
,
left
:
30
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2000
,
position
:
{
top
:
30
,
left
:
30
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2500
,
position
:
{
top
:
35
,
left
:
35
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2500
,
position
:
{
top
:
35
,
left
:
35
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
3000
,
position
:
{
top
:
40
,
left
:
40
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
3000
,
position
:
{
top
:
40
,
left
:
40
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
15000
,
position
:
{
top
:
45
,
left
:
45
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
20000
,
position
:
{
top
:
50
,
left
:
50
},
shape
:
{
width
:
45
,
height
:
95
}
},
]
]
},
},
{
{
...
@@ -58,12 +61,15 @@ export default {
...
@@ -58,12 +61,15 @@ export default {
videoUrl
:
"
//vjs.zencdn.net/v/oceans.mp4
"
,
videoUrl
:
"
//vjs.zencdn.net/v/oceans.mp4
"
,
trackData
:
[
trackData
:
[
{
time
:
0
,
position
:
{
top
:
0
,
left
:
0
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
500
,
position
:
{
top
:
15
,
left
:
15
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
500
,
position
:
{
top
:
15
,
left
:
15
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1000
,
position
:
{
top
:
20
,
left
:
20
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1000
,
position
:
{
top
:
20
,
left
:
20
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1500
,
position
:
{
top
:
25
,
left
:
25
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
1500
,
position
:
{
top
:
25
,
left
:
25
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2000
,
position
:
{
top
:
30
,
left
:
30
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2000
,
position
:
{
top
:
30
,
left
:
30
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2500
,
position
:
{
top
:
35
,
left
:
35
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
2500
,
position
:
{
top
:
35
,
left
:
35
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
3000
,
position
:
{
top
:
40
,
left
:
40
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
3000
,
position
:
{
top
:
40
,
left
:
40
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
15000
,
position
:
{
top
:
45
,
left
:
45
},
shape
:
{
width
:
45
,
height
:
95
}
},
{
time
:
20000
,
position
:
{
top
:
50
,
left
:
50
},
shape
:
{
width
:
45
,
height
:
95
}
},
]
]
},
},
{
{
...
@@ -76,7 +82,10 @@ export default {
...
@@ -76,7 +82,10 @@ export default {
hairColor
:
"
黑色
"
,
hairColor
:
"
黑色
"
,
picture
:
picture
:
"
http://10.2.100.131/tianwang/images/%E8%A7%86%E9%A2%91%E7%BB%93%E6%9E%84%E5%8C%96/u319.png
"
,
"
http://10.2.100.131/tianwang/images/%E8%A7%86%E9%A2%91%E7%BB%93%E6%9E%84%E5%8C%96/u319.png
"
,
videoUrl
:
"
//vjs.zencdn.net/v/oceans.mp4
"
videoUrl
:
"
//vjs.zencdn.net/v/oceans.mp4
"
,
trackData
:
[
{
time
:
0
,
position
:
{
top
:
20
,
left
:
20
},
shape
:
{
width
:
45
,
height
:
95
}
},
]
},
},
{
{
id
:
4
,
id
:
4
,
...
@@ -88,7 +97,7 @@ export default {
...
@@ -88,7 +97,7 @@ export default {
hairColor
:
"
黑色
"
,
hairColor
:
"
黑色
"
,
picture
:
picture
:
"
http://10.2.100.131/tianwang/images/%E8%A7%86%E9%A2%91%E7%BB%93%E6%9E%84%E5%8C%96/u337.png
"
,
"
http://10.2.100.131/tianwang/images/%E8%A7%86%E9%A2%91%E7%BB%93%E6%9E%84%E5%8C%96/u337.png
"
,
videoUrl
:
"
http://skynet-test.inajiu.com:7011/sn-web/video/video
"
videoUrl
:
"
http://skynet-test.inajiu.com:7011/sn-web/video/video
?a=abc.mp4
"
},
},
{
{
id
:
5
,
id
:
5
,
...
...
src/views/dashboard/index.vue
View file @
4a57014d
...
@@ -11,7 +11,13 @@
...
@@ -11,7 +11,13 @@
</div>
</div>
</div>
</div>
<div
class=
"player"
ref=
"player-container"
>
<div
class=
"player"
ref=
"player-container"
>
<MyVideo
v-if=
"width > 0 && videoUrl"
:src=
"videoUrl"
:trackData=
"trackData"
:width=
"width"
/>
<MyVideo
ref=
"myVideo"
v-if=
"width > 0 && videoUrl"
:src=
"videoUrl"
:trackData=
"trackData"
:width=
"width"
/>
</div>
</div>
<div
class=
"video-list"
>
<div
class=
"video-list"
>
<div
class=
"title"
>
犬只记录
</div>
<div
class=
"title"
>
犬只记录
</div>
...
@@ -60,7 +66,8 @@ export default class Dashboard extends BaseVue {
...
@@ -60,7 +66,8 @@ export default class Dashboard extends BaseVue {
handlePlay
(
dog
:
DogData
):
void
{
handlePlay
(
dog
:
DogData
):
void
{
this
.
videoUrl
=
dog
.
videoUrl
;
this
.
videoUrl
=
dog
.
videoUrl
;
this
.
trackData
=
dog
.
trackData
;
this
.
trackData
=
dog
.
trackData
;
console
.
log
(
"
dog
"
,
this
.
videoUrl
,
this
.
trackData
);
//@ts-ignore
this
.
$refs
[
"
myVideo
"
].
onSrcChange
(
this
.
videoUrl
,
this
.
trackData
);
}
}
}
}
</
script
>
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment