matrix_components 2.0.319 → 2.0.320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/ComponentDemo/VideoDemo.vue +132 -187
- package/dist/matrix_components.css +1 -1
- package/dist/matrix_components.js +25 -29
- package/dist/matrix_components.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/ComponentDemo/VideoDemo copy 2.vue +0 -268
- package/dist/ComponentDemo/VideoDemo copy 3.vue +0 -356
- package/dist/ComponentDemo/VideoDemo copy.vue +0 -289
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { onMounted, reactive, ref
|
|
3
|
-
import { useVideoDraw } from '../hooks/videoDraw'
|
|
2
|
+
import { onMounted, reactive, ref } from 'vue'
|
|
4
3
|
|
|
5
4
|
const nsVideoRef = ref()
|
|
6
5
|
|
|
@@ -9,7 +8,7 @@ const videoData = reactive({
|
|
|
9
8
|
// videoModel: 'hk',
|
|
10
9
|
// hkPath: '/martrix/cdn/h5player',
|
|
11
10
|
// 显示视频关闭按钮
|
|
12
|
-
showClose:
|
|
11
|
+
showClose: true,
|
|
13
12
|
// 显示树
|
|
14
13
|
showTree: true,
|
|
15
14
|
// 树数据
|
|
@@ -106,6 +105,39 @@ const videoData = reactive({
|
|
|
106
105
|
channelId: 'c11',
|
|
107
106
|
},
|
|
108
107
|
},
|
|
108
|
+
// {
|
|
109
|
+
// index: 1,
|
|
110
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000015.live.flv',
|
|
111
|
+
// info: {
|
|
112
|
+
// videoModel: 'easyplayer',
|
|
113
|
+
// id: '222',
|
|
114
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000015.live.flv',
|
|
115
|
+
// deviceId: 'c2',
|
|
116
|
+
// channelId: 'c11',
|
|
117
|
+
// },
|
|
118
|
+
// },
|
|
119
|
+
// {
|
|
120
|
+
// index: 2,
|
|
121
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000009.live.flv',
|
|
122
|
+
// info: {
|
|
123
|
+
// videoModel: 'easyplayer',
|
|
124
|
+
// id: 'xxx2',
|
|
125
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000009.live.flv',
|
|
126
|
+
// deviceId: 'c3',
|
|
127
|
+
// channelId: 'c11',
|
|
128
|
+
// },
|
|
129
|
+
// },
|
|
130
|
+
// {
|
|
131
|
+
// index: 3,
|
|
132
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000008.live.flv',
|
|
133
|
+
// info: {
|
|
134
|
+
// videoModel: 'easyplayer',
|
|
135
|
+
// id: 'b3',
|
|
136
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000008.live.flv',
|
|
137
|
+
// deviceId: 'c4',
|
|
138
|
+
// channelId: 'c11',
|
|
139
|
+
// },
|
|
140
|
+
// },
|
|
109
141
|
],
|
|
110
142
|
// !!! 单点播放
|
|
111
143
|
videoSingleUrl: false,
|
|
@@ -137,220 +169,133 @@ const videoData = reactive({
|
|
|
137
169
|
hasAudio: false,
|
|
138
170
|
stretch: false
|
|
139
171
|
},
|
|
172
|
+
// -----------事件回调-------------
|
|
173
|
+
// 点击树节点的操作
|
|
174
|
+
treeClick: () => {
|
|
175
|
+
console.log('点击树节点回调函数')
|
|
176
|
+
},
|
|
177
|
+
// 双击树节点的操作
|
|
178
|
+
treeDBClick: () => {
|
|
179
|
+
console.log('双击树节点回调函数')
|
|
180
|
+
},
|
|
181
|
+
// 右键树展示菜单
|
|
182
|
+
treeRightMenu: () => {
|
|
183
|
+
console.log('右键树展示菜单')
|
|
184
|
+
},
|
|
185
|
+
// 展开树节点
|
|
186
|
+
treeExpand: () => {
|
|
187
|
+
console.log('展开树节点')
|
|
188
|
+
},
|
|
189
|
+
// 视频错误回调函数
|
|
190
|
+
videoError: () => {
|
|
191
|
+
console.log('视频错误回调函数')
|
|
192
|
+
},
|
|
140
193
|
})
|
|
141
194
|
|
|
142
|
-
const drawW = ref('0')
|
|
143
|
-
const drawH = ref('0')
|
|
144
|
-
const videoPlayerCoverRef = ref()
|
|
145
|
-
const videoDrawRef = ref()
|
|
146
|
-
const canvasRef = ref()
|
|
147
|
-
|
|
148
|
-
// 使用画布绘图功能
|
|
149
|
-
const {
|
|
150
|
-
initCanvas,
|
|
151
|
-
clearCanvas,
|
|
152
|
-
drawFromCoordinates,
|
|
153
|
-
getState,
|
|
154
|
-
points,
|
|
155
|
-
areaCoordinates,
|
|
156
|
-
isDrawing,
|
|
157
|
-
isComplete
|
|
158
|
-
} = useVideoDraw()
|
|
159
|
-
|
|
160
195
|
// 视频操作事件
|
|
161
196
|
const videoEvent = {
|
|
162
197
|
videoOriginalInfo: (info: any) => {
|
|
163
198
|
console.log('===============>视频原始信息:', info)
|
|
164
|
-
const coverEle = videoPlayerCoverRef.value;
|
|
165
|
-
const currentVideoInfo = info?.[0]
|
|
166
|
-
if(coverEle && currentVideoInfo?.width && currentVideoInfo?.height){
|
|
167
|
-
let _w = coverEle.clientWidth
|
|
168
|
-
let _h = coverEle.clientHeight
|
|
169
|
-
if(currentVideoInfo.width > currentVideoInfo.height){
|
|
170
|
-
_h = _w * (currentVideoInfo.height / currentVideoInfo.width)
|
|
171
|
-
}else{
|
|
172
|
-
_w = _h * (currentVideoInfo.width / currentVideoInfo.height)
|
|
173
|
-
}
|
|
174
|
-
drawW.value = _w + 'px'
|
|
175
|
-
drawH.value = _h + 'px'
|
|
176
|
-
|
|
177
|
-
// 初始化画布绘图功能
|
|
178
|
-
nextTick(() => {
|
|
179
|
-
if (canvasRef.value && videoDrawRef.value) {
|
|
180
|
-
// 确保canvas尺寸正确
|
|
181
|
-
canvasRef.value.width = videoDrawRef.value.clientWidth
|
|
182
|
-
canvasRef.value.height = videoDrawRef.value.clientHeight
|
|
183
|
-
|
|
184
|
-
initCanvas(canvasRef.value, videoDrawRef.value)
|
|
185
|
-
console.log('画布绘图功能已初始化,尺寸:', videoDrawRef.value.clientWidth, 'x', videoDrawRef.value.clientHeight)
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
199
|
},
|
|
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
|
-
|
|
200
|
+
up: () => {
|
|
201
|
+
console.log('视频向上移动操作')
|
|
202
|
+
},
|
|
203
|
+
down: () => {
|
|
204
|
+
console.log('视频向下移动操作')
|
|
205
|
+
},
|
|
206
|
+
left: () => {
|
|
207
|
+
console.log('视频向左移动操作')
|
|
208
|
+
},
|
|
209
|
+
right: () => {
|
|
210
|
+
console.log('视频向右移动操作')
|
|
211
|
+
},
|
|
212
|
+
zoomin: () => {
|
|
213
|
+
console.log('视频放大操作')
|
|
214
|
+
},
|
|
215
|
+
zoomout: () => {
|
|
216
|
+
console.log('视频缩小操作')
|
|
217
|
+
},
|
|
218
|
+
stop: () => {
|
|
219
|
+
console.log('视频停止操作')
|
|
220
|
+
},
|
|
221
|
+
speed: () => {
|
|
222
|
+
console.log('设置视频移动速度')
|
|
223
|
+
},
|
|
224
|
+
speak: () => {
|
|
225
|
+
console.log('视频开始说话')
|
|
226
|
+
},
|
|
227
|
+
scan: () => {
|
|
228
|
+
console.log('视频扫描')
|
|
229
|
+
},
|
|
230
|
+
cruise: () => {
|
|
231
|
+
console.log('视频巡航')
|
|
232
|
+
},
|
|
233
|
+
call: () => {
|
|
234
|
+
console.log('视频调用')
|
|
235
|
+
},
|
|
220
236
|
}
|
|
221
237
|
|
|
222
238
|
onMounted(() => {
|
|
223
|
-
//
|
|
239
|
+
// setTimeout(() => {
|
|
240
|
+
// // !!!暴露方法
|
|
241
|
+
// // nsVideoRef.value.[setVideoUrl / removeVideo / fouceIndex / videoInfos / treeRef]
|
|
242
|
+
// // 设置视频
|
|
243
|
+
// videoData.videoInfos = [
|
|
244
|
+
// {
|
|
245
|
+
// index: 1,
|
|
246
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000004.live.flv',
|
|
247
|
+
// info: {
|
|
248
|
+
// videoModel: 'easyplayer',
|
|
249
|
+
// id: 'xxx',
|
|
250
|
+
// label: '视频A--3',
|
|
251
|
+
// url: 'ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000004.live.flv',
|
|
252
|
+
// deviceId: 'c1',
|
|
253
|
+
// channelId: 'c11',
|
|
254
|
+
// },
|
|
255
|
+
// },
|
|
256
|
+
// ]
|
|
257
|
+
// // }, 3000)
|
|
258
|
+
// setTimeout(() => {
|
|
259
|
+
// // 关闭视频方法1:
|
|
260
|
+
// nsVideoRef.value.removeVideo(7, true)
|
|
261
|
+
// // 关闭视频方法2:
|
|
262
|
+
// // nsVideoRef.value.setVideoUrl('', false, 7)
|
|
263
|
+
// }, 5000)
|
|
264
|
+
// 播放视频
|
|
265
|
+
// nextTick(()=>{
|
|
266
|
+
// nsVideoRef.value.setVideoUrl('ws://199.10.9.192:30200/rtp/34020000001110000001_34020000001320000010.live.flv', false, 1, {
|
|
267
|
+
// videoModel: 'easyplayer',
|
|
268
|
+
// /* videoModel: 'hk',
|
|
269
|
+
// hkPath: '/xxxx', */
|
|
270
|
+
// })
|
|
271
|
+
// })
|
|
224
272
|
})
|
|
225
|
-
|
|
226
273
|
function changeSplitHandler(num: number) {
|
|
227
274
|
console.log('分屏模式:如1,2,3代表单屏,四屏,九屏', num)
|
|
228
275
|
}
|
|
229
276
|
</script>
|
|
230
|
-
|
|
231
277
|
<template>
|
|
232
278
|
<div class="video-demo">
|
|
233
279
|
<h1 class="title" style="color: #fff" v-sline>视频组件(国标28181 + 海康威视)</h1>
|
|
234
|
-
|
|
235
|
-
<!-- 画布控制面板 -->
|
|
236
|
-
<div class="canvas-controls" v-if="isDrawing || isComplete">
|
|
237
|
-
<div class="canvas-status">
|
|
238
|
-
<span>绘图状态: {{ isDrawing ? '绘制中' : isComplete ? '已完成' : '未开始' }}</span>
|
|
239
|
-
<span>点数: {{ points.length }}</span>
|
|
240
|
-
<span v-if="areaCoordinates">区域: {{ areaCoordinates.width }} × {{ areaCoordinates.height }}</span>
|
|
241
|
-
</div>
|
|
242
|
-
<div class="canvas-buttons">
|
|
243
|
-
<button @click="clearCanvas" class="btn-clear">清除画布</button>
|
|
244
|
-
<button @click="testDrawFromCoordinates" class="btn-test">测试回显</button>
|
|
245
|
-
<button @click="showDrawInfo" class="btn-info">显示坐标</button>
|
|
246
|
-
</div>
|
|
247
|
-
</div>
|
|
248
|
-
|
|
249
280
|
<NsVideo class="nsvideo" ref="nsVideoRef" v-bind="videoData" v-on="videoEvent" @changeSplit='changeSplitHandler'>
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
281
|
+
<!-- 自定义插槽
|
|
282
|
+
<template #video-tree><span>左侧树-自定义插槽</span></template>
|
|
283
|
+
<template #video-player-head><span>播放区域头部-自定义插槽</span></template>
|
|
284
|
+
<template #video-player-view><span>播放区域主体-自定义插槽</span></template>
|
|
285
|
+
<template #video-player-foot><span>播放区域底部控制按钮-自定义插槽</span></template>
|
|
286
|
+
<template #video-player-cover><span>播放器canvas画布区域(除head+foot+tree区域)</span></template>
|
|
287
|
+
-->
|
|
257
288
|
</NsVideo>
|
|
258
289
|
</div>
|
|
259
290
|
</template>
|
|
260
|
-
|
|
261
291
|
<style scoped lang="scss">
|
|
262
292
|
.video-demo {
|
|
263
293
|
display: flex;
|
|
264
294
|
flex-direction: column;
|
|
265
295
|
height: 100%;
|
|
266
296
|
background-color: #0f2a3b;
|
|
267
|
-
|
|
268
297
|
.title {
|
|
269
298
|
margin-bottom: 10px;
|
|
270
299
|
}
|
|
271
|
-
|
|
272
|
-
// 画布控制面板样式
|
|
273
|
-
.canvas-controls {
|
|
274
|
-
background: rgba(255, 255, 255, 0.1);
|
|
275
|
-
padding: 10px;
|
|
276
|
-
border-radius: 4px;
|
|
277
|
-
margin-bottom: 10px;
|
|
278
|
-
display: flex;
|
|
279
|
-
justify-content: space-between;
|
|
280
|
-
align-items: center;
|
|
281
|
-
|
|
282
|
-
.canvas-status {
|
|
283
|
-
display: flex;
|
|
284
|
-
gap: 15px;
|
|
285
|
-
color: #fff;
|
|
286
|
-
font-size: 14px;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.canvas-buttons {
|
|
290
|
-
display: flex;
|
|
291
|
-
gap: 10px;
|
|
292
|
-
|
|
293
|
-
button {
|
|
294
|
-
padding: 6px 12px;
|
|
295
|
-
border: none;
|
|
296
|
-
border-radius: 4px;
|
|
297
|
-
cursor: pointer;
|
|
298
|
-
font-size: 12px;
|
|
299
|
-
transition: background-color 0.3s;
|
|
300
|
-
|
|
301
|
-
&.btn-clear {
|
|
302
|
-
background: #ff6b6b;
|
|
303
|
-
color: white;
|
|
304
|
-
|
|
305
|
-
&:hover {
|
|
306
|
-
background: #ff5252;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
&.btn-test {
|
|
311
|
-
background: #4ecdc4;
|
|
312
|
-
color: white;
|
|
313
|
-
|
|
314
|
-
&:hover {
|
|
315
|
-
background: #26a69a;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
&.btn-info {
|
|
320
|
-
background: #45b7d1;
|
|
321
|
-
color: white;
|
|
322
|
-
|
|
323
|
-
&:hover {
|
|
324
|
-
background: #3498db;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.video-player-cover {
|
|
332
|
-
pointer-events: none;
|
|
333
|
-
position: absolute;
|
|
334
|
-
top: 0;
|
|
335
|
-
left: 0;
|
|
336
|
-
width: 100%;
|
|
337
|
-
height: 100%;
|
|
338
|
-
display: flex;
|
|
339
|
-
justify-content: center;
|
|
340
|
-
align-items: center;
|
|
341
|
-
|
|
342
|
-
.video-draw {
|
|
343
|
-
pointer-events: auto;
|
|
344
|
-
width: v-bind(drawW);
|
|
345
|
-
height: v-bind(drawH);
|
|
346
|
-
|
|
347
|
-
.video-canvas {
|
|
348
|
-
width: 100%;
|
|
349
|
-
height: 100%;
|
|
350
|
-
background-color: rgba(0, 255, 234, 0.1);
|
|
351
|
-
cursor: crosshair;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
300
|
}
|
|
356
301
|
</style>
|