问题
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