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

1

1

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

Lekishalela answered 19/7, 2019 at 19:5 Comment(0)
I
2

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!

Informed answered 19/7, 2019 at 20:4 Comment(1)
Oof, good to know. In terms of decoding the wav data, where can I find more information on this?Lekishalela

© 2022 - 2024 — McMap. All rights reserved.