Commit 2162ae08 by Tianqing Liu

feat: 支持录像

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