flv.js icon indicating copy to clipboard operation
flv.js copied to clipboard

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

Open YOUCANSHIN opened this issue 2 years ago • 4 comments

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咋改?

YOUCANSHIN avatar Feb 24 '22 06:02 YOUCANSHIN

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

hnjz-zjh avatar Apr 06 '22 09:04 hnjz-zjh

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

qsc19971022 avatar Apr 10 '22 14:04 qsc19971022

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

shady-xia avatar Jul 20 '22 06:07 shady-xia

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

leochen-g avatar Apr 29 '24 07:04 leochen-g