bilibili / flv.js

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

Uncaught TypeError: Cannot read property 'currentURL' of null at TransmuxingController._reportStatisticsInfo (transmuxing-controller.js:423) #530

Open woow-wu7 opened 4 years ago

woow-wu7 commented 4 years ago
<template>
  <!-- flv视频播放器 -->
  <div class="container">
    <video muted ref="videoElements" controls
           :width="400" :height="400"
    />
  </div>
</template>

<script>
  import flvjs from 'flv.js'

  export default {
    data() {
      return {
        videoElement: null
      }
    },
    props: {
      flvUrl: {
        type: String,
        defatult: function() {
          return ''
        }
      },
      options: {
        type: Object,
        default: function() {
          return {
            width: 400,
            height: 400
          }
        }
      }
    },
    mounted() {
      this.createFlvPlayer()
      flvjs.getFeatureList()
      flvjs.LoggingControl.addLogListener(function(type, str){
        console.log(type+str, '999999999999999999999999');
      });
    },
    methods: {
      createFlvPlayer() {
        if (flvjs.isSupported()) {
          this.videoElement = this.$refs.videoElements;
          this.videoElement && this.watchFlvUrl()

          this.videoElement.addEventListener('play', () => {
            this.$emit('emitPlayerPlays', 1)
          })
        }
      },
      watchFlvUrl() {
        const flvPlayer = flvjs.createPlayer({
          type: 'flv',
          // isLive: true,
          cors: true,
          url: this.flvUrl || '',
        });
        flvPlayer.attachMediaElement(this.videoElement);
        flvPlayer.load();
        flvPlayer.play();
        flvPlayer.on(flvjs.Events.LOADING_COMPLETE,function(){
          //断流后做的
          console.log(object);
        })
      }
    },
    watch: {
      flvUrl: function(val, old) {
        if(val) {
          this.watchFlvUrl()
        } else {

        }
      }
    }
  }
</script>

<style scoped lang="scss">
  .container {
    position: relative;
    width: 100%;

    .videoElement {
      width: 100%;
      height: 500px;
    }
  }
</style>

调用栈:

_reportStatisticsInfo() {
        let info = {};

        ------> info.url = this._ioctl.currentURL; <---------
        info.hasRedirect = this._ioctl.hasRedirect;
        if (info.hasRedirect) {
            info.redirectedURL = this._ioctl.currentRedirectedURL;
        }

        info.speed = this._ioctl.currentSpeed;
        info.loaderType = this._ioctl.loaderType;
        info.currentSegmentIndex = this._currentSegmentIndex;
        info.totalSegmentCount = this._mediaDataSource.segments.length;

        this._emitter.emit(TransmuxingEvents.STATISTICS_INFO, info);
    }
  start() {
        this._loadSegment(0);
        this._enableStatisticsReporter();
    }
this._transmuxer.open();
 if (typeof handler === 'function') {
    ReflectApply(handler, this, args);
  } else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      ReflectApply(listeners[i], this, args);
  }
 if (typeof handler === 'function') {
    ReflectApply(handler, this, args);
  } else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      ReflectApply(listeners[i], this, args);
  }
this._emitter.emit(MSEEvents.SOURCE_OPEN);
woow-wu7 commented 4 years ago

QQ截图20191212091321 QQ截图20191212091355 3 QQ截图20191212091519

DucThanh1997 commented 4 years ago

Have you found the solution yet?

lamanlin commented 4 years ago

找到解决办法了吗

zhaolin8 commented 3 years ago

找到解决办法了吗?

woow-wu7 commented 3 years ago

都不记得当时怎么做的了,有很久都没有弄这方面的东西了

zhaolin8 notifications@github.com 于2020年12月7日周一 上午11:32写道:

找到解决办法了吗?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bilibili/flv.js/issues/530#issuecomment-739641961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGJM2ENJECNMMKDOOMT7GRLSTREFTANCNFSM4JZXQEDQ .

yetingmao commented 3 years ago

这个问题还没有解决方案吗

tommickey2020 commented 3 years ago

同问

lfl976 commented 2 years ago

我也遇到这个错了,发现是flv文件有问题

allblueee commented 2 years ago

重新启动发现没这个问题了

xiaobaidadada commented 4 weeks ago

原因可能是,flv.js最开始接收到的数据,没有flv数据的文件头。我是使用ffmpeg将rstp转换成flv然后利用websocket推送给flv.js,如果在创建一个flv.js直接利用前一个flv.js接收到的数据,是没有flv文件头的,会解析出错,必须再次创建一个新的ffmpeg转换器搭推送到flv.js。