Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Audio - Check supported formats

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?

like image 783
MiJyn Avatar asked Oct 19 '25 10:10

MiJyn


1 Answers

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:

enter image description here

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


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!