1.将cyberplayer的文件放到项目中,在index.html中引入

<script src="./static/player/cyberplayer.js"></script>

2.在.vue中创建一个DIV <DIV ref='live'></DIV>

3.

setTimeout(() => {
  this.player = cyberplayer(this.$refs.live).setup({
    width: 580,
    height: 530,
    file: this.url,
    backcolor: '#FFFFFF',
    autostart: true,
    stretching: 'uniform',
    volume: 100,
    controls: 'over',
    ak: '515d61b893134f40bd4297b75a03494b'
  })
}, 150)

如果没有setTimeout方法,会报: Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()错误

4.

beforeDestroy () {
  this.player.remove()
},
destroyed () {
  this.$off()
  this.$destroy()
}

在点击一个新的视频前,执行上面的操作会防止播放多个造成的错误

转:

http://alonesuperman.com/?p=23

https://www.jianshu.com/p/1ab09a69b6d0

https://segmentfault.com/q/1010000007130230

Logo

前往低代码交流专区

更多推荐