zhangwei
3 天以前 33c5adad9cec6581ba4c0db54959d0fec0ec9756
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<template>
    <div class="sys-video-container">
        <el-container>
            <el-header>视频监控(萤石云云直播)</el-header>
            <el-container>
                <el-aside width="200px">
                    <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" />
                </el-aside>
 
                <el-main>
                    <div class="updateToken" props="ezviz_video">
                        <ul>
                            <li>
                                <el-span>密匙串:</el-span>
                                <el-input
                                    placeholder="密匙"
                                    show-word-limit
                                    type="text"
                                    id="txt_token"
                                    title="每周更新(开放平台,云直播,轻应用,代码示例)"
                                    v-model="ezviz_video.ezvizToken"
                                    @keyup.enter="update_Token"
                                    class="token_input"
                                />
                            </li>
                            <li>
                                <el-span>视频流:</el-span>
                                <el-input
                                    placeholder="萤石云视频流地址"
                                    show-word-limit
                                    type="text"
                                    id="txt_url"
                                    title="密匙对应的视频流地址(高清后缀.h.live)"
                                    v-model="ezviz_video.ezvizUrl"
                                    @keyup.enter="update_Token"
                                    class="token_input"
                                />
                            </li>
                        </ul>
                    </div>
 
                    <div class="video">
                        <div class="video-item">
                            <div class="item">
                                <div class="home" ref="viewtoolOne">
                                    <div id="video-container">等待加载...</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>
 
<!-- 
库:https://github.com/Ezviz-OpenBiz/EZUIKit-JavaScript-npm
安装:npm install ezuikit-js 或 pnpm add ezuikit-js
-->
<script lang="ts" setup name="video">
import { reactive, ref, onMounted, nextTick, beforeDestroy } from 'vue';
import EZUIKit from 'ezuikit-js'; //页面引用
//import { ElNotification } from 'element-plus';
//import { Search,ChatDotSquare,TopRight,Star,Operation,Setting,Connection,Discount,Open,Delete,Position,View,CopyDocument,DocumentChecked,VideoCamera} from '@element-plus/icons-vue';
import mittBus from '/@/utils/mitt'; //事件总线mitt 解决打包后错误Uncaught (in promise) ReferenceError: Cannot access 'oe' before initialization
 
let ezvizPlayOne = ref(null);
let ezvizPlayTwo = ref(null);
let ezvizPlayThree = ref(null);
let ezvizPlayFour = ref(null);
let viewtoolOne = ref();
let viewtoolTwo = ref();
let viewtoolThree = ref();
let viewtoolFour = ref();
 
interface Tree {
    label: string;
    children?: Tree[];
}
 
const defaultProps = {
    children: 'children',
    label: 'label',
};
 
const handleNodeClick = (data: Tree) => {
    console.log(data);
};
 
// 更新token
function update_Token(e) {
    //ezviz_video.ezvizToken=e.target.value;
    console.log(e.target.value);
    autoVideoOne('video-container');
}
 
onMounted(async () => {
    autoVideoOne('video-container');
    //console.log('https://open.ys7.com/console/ezuikit/template/detail.html?themeId=pcLive&editing=false');
});
 
// 测试 ezopen://open.ys7.com/G39444019/1.live 和 at.3bvmj4ycamlgdwgw1ig1jruma0wpohl6-48zifyb39c-13t5am6-yukyi86mz
// 备用 ezopen://open.ys7.com/AA2615287/1.live 和 ra.5k88qgc34vgr9yva7rlub985blo9ph7k-92q0bl2r4r-0aygaog-5cofhebpm
const ezviz_video = reactive({
    ezvizToken: 'ra.5k88qgc34vgr9yva7rlub985blo9ph7k-92q0bl2r4r-0aygaog-5cofhebpm', //需要修改每周(开放平台,云直播,轻应用,代码示例中找)演示设备
    ezvizUrl: 'ezopen://open.ys7.com/AA2615287/1.live', //高清直播拼接字符串   cosnt url = `ezopen://${item.identifyingCode}@open.ys7.com/${item.imei}/${item.channelNo}.hd.live`
    // 回放地址ezopen://open.ys7.com/AA2615287/1.rec
});
 
// beforeDestroy(()=>{
//     ezvizPlayOne.value  && ezvizPlayOne.value.stop() //销毁并停止直播视频
//     console.log('beforeDestroy');
// });
 
// 监控1,参数https://blog.csdn.net/weixin_53791978/article/details/126489296
function autoVideoOne(params) {
    // 获取父节点的宽高
    let divW = viewtoolOne.value.clientWidth;
    let divH = viewtoolOne.value.clientHeight;
    if (ezvizPlayOne.value != null) {
        return;
    }
 
    // 获取萤石token
    ezvizPlayOne.value = new EZUIKit.EZUIKitPlayer({
        autoplay: true, // 默认播放
        // 视频播放包括元素
        id: 'video-container', //DIV容器
        // 萤石token,https://open.ys7.com/console/ezuikit/template/detail.html?themeId=pcLive&editing=false中查询实例代码
        accessToken: ezviz_video.ezvizToken, //"ra.bl9n4hmb3c7w4fk6bbuumtmdcbbo66w0-3k7nal0q6y-0lp00m5-fi61isesz",
        // ezopen://open.ys7.com/${设备序列号}/{通道号}.live
        url: ezviz_video.ezvizUrl, //"ezopen://open.ys7.com/AA2615287/1.live", // 播放地址
        template: 'standard', // pcLive,simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版;theme-可配置主题;
        useHardDev: true, // 开启高性能模式 依赖需高于7.7.x 截止到2023.11.7 建议保持最新版本为7.7.6
        // header: ['capturePicture', 'zoom'], // 如果templete参数不为simple,该字段将被覆盖
        //plugin: ['talk'], // 加载插件,talk-对讲
        // 视频下方底部控件
        //footer: ["talk", "broadcast", "hd", "fullScreen"], // 如果template参数不为simple,该字段将被覆盖
        footer: ['talk', 'hd', 'fullScreen'], // 如果template参数不为simple,该字段将被覆盖
        //audio: 0, // 是否默认开启声音 0 - 关闭 1 - 开启
        // openSoundCallBack: data => console.log("开启声音回调", data),
        // closeSoundCallBack: data => console.log("关闭声音回调", data),
        // startSaveCallBack: data => console.log("开始录像回调", data),
        // stopSaveCallBack: data => console.log("录像回调", data),
        // capturePictureCallBack: data => console.log("截图成功回调", data),
        // fullScreenCallBack: data => console.log("全屏回调", data),
        // getOSDTimeCallBack: data => console.log("获取OSDTime回调", data),
        width: divW,
        height: divH,
        handleError: (err: any) => {
            if (err.type === 'handleRunTimeInfoError' && err.data.nErrorCode === 5) {
                console.log('加密设备密码错误');
            }
        },
    });
}
 
const data: Tree[] = [
    {
        label: '节点A',
        children: [
            {
                label: '菜单A-1',
                children: [
                    {
                        label: '菜单A-1-1',
                    },
                ],
            },
        ],
    },
    {
        label: '节点B',
        children: [
            {
                label: '菜单B-1',
                children: [
                    {
                        label: '菜单B-1-1',
                    },
                ],
            },
            {
                label: '菜单B-2',
                children: [
                    {
                        label: '菜单B-2-1',
                    },
                ],
            },
        ],
    },
    {
        label: '节点C',
        children: [
            {
                label: '菜单C-1',
                children: [
                    {
                        label: '菜单C-1-1',
                    },
                ],
            },
            {
                label: '菜单C-2',
                children: [
                    {
                        label: '菜单C-2-1',
                    },
                ],
            },
        ],
    },
];
</script>
 
<style lang="scss" scoped>
.sys-video-container {
    overflow: hidden;
    height: 100vh;
}
.common-layout {
    background-color: #ecf5ff;
}
 
.el-header {
    text-align: center;
    height: 45px;
    line-height: 45px;
    font-size: 22px;
    background-color: #eee;
    padding: 5px auto;
}
.el-aside {
    text-align: center;
    padding: 4px auto;
    overflow: hidden;
}
.el-aside .el-form {
    text-align: center;
    padding: 2px auto;
    margin: 4px;
}
.el-aside .el-button {
    margin: 2px;
}
.el-aside .el-input {
    font-size: 14px;
    padding: 2px;
}
.el-aside .el-card {
    margin: 10px 0 10px auto;
}
.el-aside .el-card .el-button {
    width: 90px;
}
.el-form-item {
    font-weight: bold;
}
 
.el-main {
    background-color: #111;
    padding: 4px;
    width: 100%;
    overflow: hidden;
    color: #fff;
}
 
.recvs {
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    height: 800px;
}
.rev_title {
    width: 100%;
    display: block;
    font-style: italic;
    color: #999;
    font-size: 14px;
    background-color: #fafafa;
    padding: 2px 4px;
    line-height: 25px;
}
.rev_conts {
    width: 100%;
    word-wrap: break-word;
    line-height: 1.5em;
    padding: 4px;
    line-height: 30px;
} /*缩进text-indent:2em;*/
.recvfontsize {
    text-align: center;
    display: block;
    padding-top: 4px;
}
.el-color-picker {
    margin-left: 4px;
}
.recv_count {
    text-align: left;
}
.recv_count p {
    line-height: 30px;
}
 
.header {
    font-size: 24px;
    font-weight: bold;
    margin: -10px auto 10px auto;
}
 
h1 {
    font-size: 16px;
    margin-top: 10px auto 20px auto;
    padding: 5px 0px 5px 0;
}
 
.el-col {
    padding: 4px;
}
 
.el-input {
    font-size: 13px;
}
.el-card {
    margin-bottom: 12px;
}
.el-card__body {
    padding: 24px;
}
 
.el-select {
    width: 100%;
}
 
.text-right {
    text-align: right;
}
 
.sub-btn {
    margin-top: 30px;
}
 
.updateToken {
    display: block;
    line-height: 30px;
    align: left;
    background: rgb(250, 250, 250, 0.2);
    padding: 5px;
}
 
.token_input {
    width: 90%;
}
.hidden {
    display: none;
}
.w80 {
    width: 80px;
}
.w100 {
    width: 100px;
}
.log {
    font-size: 14px;
    color: #fff;
    background-color: black;
}
.center {
    text-align: center;
}
#ch1,
#ch2,
#ch3,
#ch4,
#ch5 {
    width: 120px;
}
.el-tag {
    padding: auto 4px;
    margin: 5px;
    min-width: 60px;
}
 
el-tree span {
    line-height: 50px;
}
 
.video {
    width: 100%;
    height: 100%;
    overflow: hidden;
 
    .video-item {
        display: flex;
        padding: 5px;
        overflow: hidden;
 
        .item {
            flex: 1;
 
            min-height: 40%;
            width: 100%;
            margin: 0 5px;
            background-color: #000000;
            color: #fff;
            border-radius: 2px;
 
            .home {
                width: 100%;
                height: 70vh;
                overflow: hidden;
                padding: 0;
                marigin: 0;
                aspect-ratio: 16/9; /* 设置任意宽高任意一项即可 然后使用aspect-ratio元素 动态设置比例 */
                text-align: center;
                justify-content: center;
            }
        }
    }
}
</style>