Allen More
Allen More

Reputation: 908

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

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

Upvotes: 1

Views: 2943

Answers (1)

Brad
Brad

Reputation: 163448

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!

Upvotes: 2

Related Questions