'audio/wav' mime type not supported by MSE SouceBuffer object, but audio src attribute pointing at .wav plays just fine

狂风中的少年 提交于 2020-07-22 05:53:07

问题


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');

However I get a "NotSupportedError":

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

Also, running the following:

MediaSource.isTypeSupported('audio/wav');

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

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?

I'm using Chrome 72 and firefox 68


回答1:


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

See also: https://github.com/w3c/media-source/issues/55

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!



来源:https://stackoverflow.com/questions/57118353/audio-wav-mime-type-not-supported-by-mse-soucebuffer-object-but-audio-src-att

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!