Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
woow-wu7 opened this issue Dec 12, 2019 · 10 comments

Comments

@woow-wu7
Copy link

woow-wu7 commented Dec 12, 2019

<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
Copy link
Author

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

@DucThanh1997
Copy link

Have you found the solution yet?

@lamanlin
Copy link

找到解决办法了吗

@zhaolin8
Copy link

zhaolin8 commented Dec 7, 2020

找到解决办法了吗?

@woow-wu7
Copy link
Author

woow-wu7 commented Dec 7, 2020 via email

@yetingmao
Copy link

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

@tommickey2020
Copy link

同问

@lfl976
Copy link

lfl976 commented Dec 8, 2021

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

@allblueee
Copy link

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

@xiaobaidadada
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants