In HTML5 audio, I can do this to find out if MP3 is supported:
var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
Is there a similar function for the Web Audio API? Or should I use the same function?
You can use the same function.
Web Audio API does not support other formats than what is supported in the audio element.
Currently these are:
Source:
https://en.wikipedia.org/wiki/HTML5_Audio
Just to get it correct as there is an error in this table: IE do support both Wav and Ogg. See: https://www.microsoft.com/web/post/adding-audio-with-the-new-html5-audio-tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With