Commit aa48bdd2 by Tianqing Liu

feat: 播放增加限制条件

1 parent 8c461dca
......@@ -38,6 +38,7 @@ export default {
return {
// eslint-disable-next-line
_jessibuca: null,
playing: false,
player: {
height: 0,
......@@ -48,6 +49,9 @@ export default {
mounted() {
this.init();
},
unmounted() {
this.destroy();
},
methods:{
init(params = {}) {
const options = Object.assign({
......@@ -115,6 +119,15 @@ export default {
this.player.height = data.height;
});
playerIns.on('play', (flag) => {
console.log('on-play', flag);
this.playing = true;
});
playerIns.on('pause', (flag) => {
console.log('on-pause', flag);
this.playing = false;
});
playerIns.on('ptz', (arrow) => {
// console.log('ptz', arrow);
this.$emit('ptz-control', arrow);
......@@ -144,19 +157,14 @@ export default {
if (this._jessibuca) {
this._jessibuca.destroy().then(() => {
this._jessibuca = null;
this.playing = false;
});
}
},
screenshot2(filename = '', format = 'png', quality = 0.92, type = 'base64') {
// TODO: 必须播放状态,才可获取水印
const originData = this._jessibuca.screenshot(filename, format, quality, type);
// TODO: 动态获取宽高
return getWatermarkCanvasImg(800, 480, '文安智能', originData);
},
screenshot(filename = '', format = 'png', quality = 0.92, type = 'base64') {
return new Promise((resolve, reject) => {
// 如果是播放状态
if (!this.player.height || !this.player.width ) {
if (!this.player.height || !this.player.width || !this.playing) {
reject(new Error('invaild data'));
}
......@@ -166,7 +174,7 @@ export default {
// 当图像加载完成后执行
image.onload = () => {
// 创建一个 Canvas 元素
const canvas = getWatermarkCanvasImg(this.player.width, this.player.height, '文安智能', image);;
const canvas = getWatermarkCanvasImg(this.player.width, this.player.height, this.watermarkText, image);;
// 将带有水印的 Canvas 转换回 base64
const watermarkedBase64 = canvas.toDataURL('image/png');
......
......@@ -5,7 +5,7 @@
<vion-player ref="vionPlayer"
:type="playerType"
:datetime-range="datetimeRange"
watermarkText="方案智能"
watermarkText="文安智能123"
@ptz-control="handlePtz"
/>
</div>
......@@ -68,7 +68,9 @@ export default {
console.log('handleScreenshot', data);
this.base64Url = data;
this.dialogVisible = true;
});
}).catch(err => {
console.error(err);
})
},
handlePause() {
this.$refs.vionPlayer.pause();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!