flv.js
flv.js copied to clipboard
Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/flv.js/src/core/mse-controller.js b/node_modules/flv.js/src/core/mse-controller.js
index 7974940..a2bec2c 100644
--- a/node_modules/flv.js/src/core/mse-controller.js
+++ b/node_modules/flv.js/src/core/mse-controller.js
@@ -223,6 +223,9 @@ class MSEController {
}
appendMediaSegment(mediaSegment) {
+ if (!this._mediaSource || this._mediaSource.readyState !== 'open') {
+ return;
+ }
let ms = mediaSegment;
this._pendingSegments[ms.type].push(ms);
@@ -323,6 +326,9 @@ class MSEController {
}
_needCleanupSourceBuffer() {
+ if (!this._mediaSource || this._mediaSource.readyState !== 'open') {
+ return;
+ }
if (!this._config.autoCleanupSourceBuffer) {
return false;
}
@@ -333,7 +339,7 @@ class MSEController {
let sb = this._sourceBuffers[type];
if (sb) {
let buffered = sb.buffered;

- if (buffered.length >= 1) {
+ if (buffered && buffered.length >= 1) {
if (currentTime - buffered.start(0) >= this._config.autoCleanupMaxBackwardDuration) {
return true;
}
This issue body was partially generated by patch-package.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
[email protected]
for the project I'm working on.Here is the diff that solved my problem:
diff --git a/node_modules/flv.js/src/core/mse-controller.js b/node_modules/flv.js/src/core/mse-controller.js index 7974940..a2bec2c 100644 --- a/node_modules/flv.js/src/core/mse-controller.js +++ b/node_modules/flv.js/src/core/mse-controller.js @@ -223,6 +223,9 @@ class MSEController { } appendMediaSegment(mediaSegment) { + if (!this._mediaSource || this._mediaSource.readyState !== 'open') { + return; + } let ms = mediaSegment; this._pendingSegments[ms.type].push(ms); @@ -323,6 +326,9 @@ class MSEController { } _needCleanupSourceBuffer() { + if (!this._mediaSource || this._mediaSource.readyState !== 'open') { + return; + } if (!this._config.autoCleanupSourceBuffer) { return false; } @@ -333,7 +339,7 @@ class MSEController { let sb = this._sourceBuffers[type]; if (sb) { let buffered = sb.buffered;  - if (buffered.length >= 1) { + if (buffered && buffered.length >= 1) { if (currentTime - buffered.start(0) >= this._config.autoCleanupMaxBackwardDuration) { return true; }
This issue body was partially generated by patch-package.
Nice! this is helpful!
Thanks. Will apply.
Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
This exception shouldn't occur. What's your case or scene?
就是正常播放,一开始加载出来了,然后就不停的报这个错,在我们的vue项目里面就是一直报错,然后还有一个react项目也有一个视频,也只一只报这个错,然后页面越来越卡,最后就不动了
------------------ 原始邮件 ------------------ 发件人: "bilibili/flv.js" @.>; 发送时间: 2021年7月29日(星期四) 上午8:58 @.>; @.>;"State @.>; 主题: Re: [bilibili/flv.js] Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source. (#677)
Failed to read the 'buffered' property from 'SourceBuffer': This SourceBuffer has been removed from the parent media source.
This exception shouldn't occur. What's your case or scene? edit flv.js see picture
this package still has some problem:not support ios.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.
SourceBuffer 从 parent media source 移除之后必然就不能再播放了,加检测条件都没有用
我是在nuxt(vue)使用dplayer搭配flv.js播放flv,播放时即出现该错误
@wei10cool 能否给个完整的异常时调用栈?
@wei10cool 能否给个完整的异常时调用栈?
dplay 使用方式 切换chanel时发生异常,如下
<template>
<div>
<h3>video</h3>
<v-btn @click="chchanel('a1')" color="primary">chanel_A1</v-btn>
<v-btn @click="chchanel('a2')" color="primary">chanel_A2</v-btn>
<div id="dplayer"></div>
</div>
</template>
<script>
export default {
head() {
return {
title: "myvideo",
script: [{ src: "../flv.js" }, { src: "../DPlayer.min.js" }]
};
},
data() {
return {
player: undefined,
url: "https://xxx.xxx.xxx.xxx:8443/live/170.flv",
type:'hls'
};
},
methods: {
chchanel: function(data) {
this.url = `https://xxx.xxx.xxx.xxx:8443/live/${data}.flv`;
this.player.pause();
this.player.switchVideo({
url: this.url,
type: 'flv'
});
this.player.play();
}
},
mounted() {
this.player = new DPlayer({
container: document.getElementById("dplayer"),
video: {
name: "FLV",
url: this.url,
type: "customFlv",
customType: {
customFlv: function(video, player) {
const flvPlayer = flvjs.createPlayer(
{
type: 'flv',
url: video.src,
isLive: true
},
{
enableStashBuffer: false,
//fixAudioTimestampGap: false,
isLive: true
}
);
flvPlayer.attachMediaElement(video);
flvPlayer.load();
}
}
}
});
this.player.play();
}
};
</script>
<style scoped></style>
请给 exception call stack
我也遇到了 移动端浏览器播放flv视频的时候出现这个报错
这个问题还在跟进吗?@xqq
不用的flv实例没有及时清掉,就开始创建新的实例,就会产生这个问题。
@shady-xia 为什么我及时清理了也还是会有这个问题呢
React 里用的 flv.js => 1.6.2版本 也出现以上问题: