【发布时间】:2020-09-26 15:28:57
【问题描述】:
我在我的 Web 应用程序中实现了一个简单的音频播放器,但注意到它在 Firefox 中无法正常工作(让我... ????)。
我得到的是一个错误:
ERROR DOMException: MediaSource.addSourceBuffer: Type not supported in MediaSource
这之后是一个警告:
Cannot play media. No decoders for requested formats: audio/mpeg
这是sourceopen 事件处理程序的实现:
private onSourceOpen = (e) => {
this.logger.debug('onSourceOpen');
if (!this.sourceBuffer) {
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/mpeg');
}
this.mediaSource.removeEventListener('sourceopen', this.onSourceOpen);
this.fetchRange(this.trackPlayUrl, 0, this.segmentLength, (chunk) => this.appendSegment(chunk));
}
在哪里
// Create the media source object
this.mediaSource = new MediaSource();
this.mediaSource.addEventListener('sourceopen', this.onSourceOpen);
它为什么讨厌我?
【问题讨论】:
-
不只是你。 MediaSource 讨厌所有人。 :-) 另见:stackoverflow.com/a/34498784/362536
-
@Brad 感谢您的链接。猜猜我必须使用不同的格式..也很高兴我不是一个人在这里.. ^^
标签: google-chrome firefox media-source