HHVideo.vue
2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<template>
<div>
<video :id="videoName" class="video-monitor" muted autoplay></video>
</div>
</template>
<script>
/**
* @name HHVideo
* @module src/components/HHVideo
* @desc 用于页面显示各个监控信息组件
* @author 胡菁
* @date 2024年08月12日13:39
* @example <hh-video></hh-video>
*/
export default {
components: {},
data() {
return {
webRtcServer: null,
isShow: false,
isLoad: false,
videoName: 'videoMonitor' + Math.random() * 1000,
configPar: null,
channelPar: '',
typePar: '',
servicePar: '',
}
},
props: {
type: {
type: String,
default: '0',
},
config: {
type: Object,
default: null,
},
channel: {
type: String,
default: '',
},
service: {
type: String,
default: '',
},
},
created() {},
mounted() {
this.configPar = this.$props.config
this.channelPar = this.$props.channel
this.typePar = this.$props.type
this.servicePar = this.$props.service
},
destroyed() {},
activated() {
if (this.typePar != '0') {
this.showVideo()
}
},
deactivated() {
if (this.webRtcServer != null) {
this.hideVideo()
this.isLoad = false
this.webRtcServer.disconnect()
}
},
methods: {
//显示监控
showVideo() {
if (!this.isLoad) {
if (this.webRtcServer == null) {
this.webRtcServer = new WebRtcStreamer(this.videoName, location.protocol + '//' + this.servicePar)
}
if (this.configPar != null) {
this.webRtcServer.connect(`rtsp://${this.configPar.name}:${this.configPar.password}@${this.configPar.ip}:554/Streaming/Channels/${this.channelPar}01`)
}
setTimeout(() => {
this.isLoad = true
}, 3000)
}
this.showHideDiv(true)
},
//隐藏监控
hideVideo() {
this.showHideDiv(false)
},
showHideDiv(fig) {
this.isShow = fig
},
},
}
</script>
<style lang="scss" scoped>
.hh-video {
position: absolute;
z-index: 999;
width: 100%;
height: 100%;
display: flex;
text-align: center;
align-items: center;
justify-content: center;
pointer-events: none;
}
.video-root {
width: 50%;
height: 55%;
display: flex;
align-items: center;
justify-content: center;
}
.div-image {
position: absolute;
right: -30px;
top: 0px;
cursor: pointer;
pointer-events: auto;
}
.video-monitor {
width: 100%;
height: 100%;
object-fit: fill;
//margin-top: 2%;
}
.show-area {
opacity: 1;
z-index: 9999;
}
.hidden-area {
opacity: 0;
z-index: -9999;
}
</style>