bilibili / flv.js

HTML5 FLV Player
Apache License 2.0
22.89k stars 3.39k forks source link

重复实例化播放器报错:Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer has been removed from the parent media source. #732

Open YOUCANSHIN opened 2 years ago

YOUCANSHIN commented 2 years ago

vue组件中重复实例化flvPlayer对象报错,代码如下: <video id="videoElement"></video>

data() {
    return {
      flvPlayer: null
    }
  },
playFlvJS(url) {
      this.$nextTick(function() {
        this.cameraSelected = true
        this.loadingCamera = true
        if (flvjs.isSupported()) {
          const videoElement = document.getElementById('videoElement')
          if (videoElement != null) console.log('videoElement getted')
          if (typeof player !== 'undefined') {
            if (this.flvPlayer != null) {
              this.flvPlayer.unload()
              this.flvPlayer.detachMediaElement()
              this.flvPlayer.destroy()
              this.flvPlayer = null
            }
          }
          this.flvPlayer = flvjs.createPlayer({
            type: 'flv',
            // url: 'http://192.168.51.100:8000/live/test1.flv'
            url,
            config: {
              autoCleanupSourceBuffer: true
            }
          })
          console.log('flvPlayer generated', this.flvPlayer)
          // 视频播放失败,显示提示信息
          this.flvPlayer.on('error', (err) => {
            console.log('视频错误信息回调', err)
          })
          // this.flvPlayer.on(flvjs.Events.LOADING_COMPLETE, (res) => {
          //   console.log('加载完成')
          //   this.loadingCamera = false
          // })
          this.loadingCamera = false
          this.flvPlayer.attachMediaElement(videoElement)
          this.flvPlayer.load()
          this.flvPlayer.play()
        }
      })
    },

报错的递归调用栈如下:

[MSEController] > Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer has been removed from the parent media source. webpack_modules../src/utils/logger.js.Log.e webpack_modules../src/core/mse-controller.js.MSEController._doAppendSegments __webpack_modules__../src/core/mse-controller.js.MSEController.appendMediaSegment 请问这bug咋改?

hnjz-zjh commented 2 years ago

大佬 这个 你解决了嘛?我的也是这样,在播放一段时间后,一直报这个错误,直接把内存沾满了 ,视频就播放不了

qsc19971022 commented 2 years ago

先删flv,再删dom,不要直接删dom,最近做了个直播轮播的项目,也碰到过

shady-xia commented 2 years ago

不用的flv实例要destroy清理掉,没清理掉就会报这个错

leochen-g commented 4 months ago

已经destroy了,还是会遇到这个问题