MSE SouceBuffer对象不支持'audio/wav'MIME类型,但是指向.wav的音频src属性可以正常播放 [英] 'audio/wav' mime type not supported by MSE SouceBuffer object, but audio src attribute pointing at .wav plays just fine

查看:454
本文介绍了MSE SouceBuffer对象不支持'audio/wav'MIME类型,但是指向.wav的音频src属性可以正常播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Mime类型"audio/wav"的W3 Media Source Extension API创建SourceBuffer,如下所示:

I'm trying create a SourceBuffer from the W3 Media Source Extension API with Mime type 'audio/wav' like so:

let sourceBuffer = mediaSource.addSourceBuffer('audio/wav');

但是我收到一个"NotSupportedError":

However I get a "NotSupportedError":

无法在"MediaSource"上执行"addSourceBuffer":不支持提供的类型("audio/wav").

Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('audio/wav') is unsupported.

另外,运行以下命令:

MediaSource.isTypeSupported('audio/wav');

对于最新版本的Firefox和chrome,浏览器控制台中的

返回false.

in the browser console returns false for both recent versions of firefox and chrome.

如果仅将音频标签的src设置为.wav的url,则一切正常.只有当我使用SourceBuffer时,我才会遇到文件类型支持问题.我需要指定哪个DOMString来addSourceBuffer()使其接受PCM编码的.wav文件?

If I just set the src of the audio tag to the url of the .wav, everything works fine. It's only when I use a SourceBuffer that I get file type support issues. What DOMString do I need to specify to addSourceBuffer() to have it accept a PCM encoded .wav file?

我正在使用Chrome 72和firefox 68

I'm using Chrome 72 and firefox 68

推荐答案

不幸的是,MSE并不总是支持音频/视频元素支持的媒体. audio/wav就是这种情况.

Unfortunately, media supported by audio/video elements is not always supported by MSE. This is the case for audio/wav.

另请参见: https://github.com/w3c/media-source/Issues/55

在这种情况下,您可以在自己的脚本中解码WAV文件,并使用Web Audio API中的ScriptProcessorNode进行播放.肯定是一堆乱七八糟的东西,但有可能!

In this case, you could decode the WAV file in your own script, and use the ScriptProcessorNode in the Web Audio API to play it back. A hacky mess for sure, but possible!

这篇关于MSE SouceBuffer对象不支持'audio/wav'MIME类型,但是指向.wav的音频src属性可以正常播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆