index.vue
3.52 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
140
141
142
143
144
145
146
147
148
149
150
151
<template>
<div class="vion-player" ref="container"></div>
</template>
<script>
// import { watermarkBase64 } from './data';
import { getWatermarkCanvasImg } from './utils';
export default {
name: 'VionPlayer',
props: {
type: {
type: String,
default: 'live', // playback
},
playUrl: {
type: String,
default: '', // 若配置,则播放器加载后,自动播放
},
datetimeRange: {
type: Array,
default: null,
},
watermarkText: {
type: String,
default: '',
},
controlAutoHide: {
type: Boolean,
default: true,
},
showPtz: {
type: Boolean,
default: true,
},
},
data() {
return {
// eslint-disable-next-line
_jessibuca: null,
}
},
mounted() {
this.init();
},
methods:{
init(params = {}) {
const options = Object.assign({
container: this.$refs.container,
decoder: '/jessibuca-pro/decoder-pro.js',
isResize: false,
text: '', // TODO: 功能暂不清楚
useMSE: true,
useWCS: false,
isNotMute: false,
timeout: 10,
keepScreenOn: true, // 屏幕常亮
debug: false, // 是否开启控制台调试打印
// 按钮和界面
loadingText: '加载中...',
controlAutoHide: this.controlAutoHide,
supportDblclickFullscreen: false,
showBandwidth: false, // 显示网速
// TODO: 水印功能暂不可用
/* watermarkConfig: {
image: {
src: this.getWatermarkBase64(),
width: 150,
height: 48
},
right: 10,
top: 30
}, */
operateBtns: {
fullscreen: true,
screenshot: false,
play: true,
audio: true,
ptz: true, // 云台
zoom: true,
performance: false,
},
extendOperateBtns: [],
// 云台控制
ptzClickType: 'click', // click mouseDownAndUp
ptzZoomShow: true,
ptzMoreArrowShow: true,
ptzApertureShow: true,
ptzFocusShow: true,
});
this._jessibuca = new window.JessibucaPro(options);
this.registerEvent(this._jessibuca);
if (this.playUrl) {
// 示例上有延迟写法
setTimeout(this.play(this.playUrl), 150);
}
},
registerEvent(playerIns) {
playerIns.on("log", msg => {
console.log("on-log", msg);
});
playerIns.on('ptz', (arrow) => {
// console.log('ptz', arrow);
this.$emit('ptz-control', arrow);
});
},
getWatermarkBase64() {
const data = getWatermarkCanvasImg(150, 48, '文安智能');
console.log('getWatermarkBase64', data);
},
// 暴露方法
play(url) {
if (url) {
this._jessibuca.play(url);
} else {
console.error('The url is not valid');
}
},
pause() {
this._jessibuca.pause();
},
stop() {
this._jessibuca.pause(true);
},
destroy() {
if (this._jessibuca) {
this._jessibuca.destroy().then(() => {
this._jessibuca = null;
});
}
},
screenshot(filename = '', format = 'png', quality = 0.92, type = 'base64') {
const originData = this._jessibuca.screenshot(filename, format, quality, type);
// TODO: 动态获取宽高
return getWatermarkCanvasImg(800, 480, '文安智能', originData);
},
},
}
</script>
<style lang="scss" scoped>
.vion-player {
background-color: rgba(13, 14, 27, 0.7);
}
</style>