Syntax error How to detect HTML5 audio MP3 support

How to detect HTML5 audio MP3 support



To detect HTML5 audio MP3 support, use the Modernizr library.

As stated in the official specification

 

Source − Screenshot from the official Modernizr documentation

 For detecting HTML5 audio MP3 support, you can also check the User-Agent to detect which browser is used.

You can also use JavaScript to test −

var x = document.createElement('audio');
return !!(x.canPlayType && x.canPlayType('audio/mpeg;').replace(/no/, ''));
Updated on: 2020-06-25T05:29:55+05:30

250 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements