Commit 2162ae08 by Tianqing Liu

feat: 支持录像

1 parent 17163706
......@@ -38,7 +38,10 @@ export default {
return {
// eslint-disable-next-line
_jessibuca: null,
// TODO: 播放状态应从播放器对象获取
playing: false,
isPlayed: false,
playOriginUrl: '',
player: {
height: 0,
......@@ -47,15 +50,13 @@ export default {
}
},
mounted() {
console.log("this.playUrl", this.playUrl);
this.init();
this.init(this.playUrl);
},
unmounted() {
this.destroy();
},
methods:{
init(params = {}) {
console.log("this.playUrl", this.playUrl);
init(url, params = {}) {
const options = Object.assign({
container: this.$refs.container,
decoder: '/jessibuca-pro/decoder-pro.js',
......@@ -104,10 +105,10 @@ export default {
this._jessibuca = new window.JessibucaPro(options);
this.registerEvent(this._jessibuca);
console.log("this.playUrl", this.playUrl);
if (this.playUrl) {
if (url) {
// 示例上有延迟写法
setTimeout(this.play(this.playUrl), 150);
setTimeout(this.play(url), 150);
}
},
registerEvent(playerIns) {
......@@ -136,7 +137,6 @@ export default {
});
},
getWatermarkBase64() {
const data = getWatermarkCanvasImg(150, 48, '文安智能');
console.log('getWatermarkBase64', data);
},
......@@ -144,7 +144,14 @@ export default {
// 暴露方法
play(url) {
if (url) {
// 播放地址不同,则先停止再播放。
if (this.playOriginUrl && this.playOriginUrl !== url) {
this.stop();
}
setTimeout(() => {
this._jessibuca.play(url);
this.playOriginUrl = url;
}, 150);
} else {
console.error('The url is not valid');
}
......@@ -153,14 +160,18 @@ export default {
this._jessibuca.pause();
},
stop() {
this._jessibuca.pause(true);
this._jessibuca.close();
},
destroy() {
if (this._jessibuca) {
this._jessibuca.destroy().then(() => {
this._jessibuca = null;
this.playing = false;
}).catch(() => {
Promise.reject(new Error('destruction failed'));
});
} else {
Promise.resolve(true);
}
},
screenshot(filename = '', format = 'png', quality = 0.92, type = 'base64') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!