flv.js
flv.js copied to clipboard
Uncaught TypeError: Cannot read property 'currentURL' of null at TransmuxingController._reportStatisticsInfo (transmuxing-controller.js:423)
<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);
Have you found the solution yet?
找到解决办法了吗
找到解决办法了吗?
都不记得当时怎么做的了,有很久都没有弄这方面的东西了
zhaolin8 [email protected] 于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 .
这个问题还没有解决方案吗
同问
我也遇到这个错了,发现是flv文件有问题
我也遇到这个错了,发现是chrome浏览器版本低了
重新启动发现没这个问题了