0

I'm trying to use Modernizr to detect if the browser supports certain audio codecs, and it doesn't seem to be doing what I expected.

I ran the following

if(Modernizr.audio.mp4){

     //Do Something

}

But when I tested on Safari (which supports MP4), any logic inside the brackets was not hit. Perhaps I have my logic wrong, or I'm not understanding what Modernizr actually does?

All I want to do is test if the browser supports MP4 audio or not. Modernizr seemed to be the consensus to do this.

Any insights?

Thanks!

1
  • 1
    From the documentation: "Modernizr tests ogg, mp3, wav and m4a." Maybe you meant to type m4a instead of mp4? Jun 2, 2014 at 19:34

1 Answer 1

1

You're probably looking for Modernizr.audio.m4a.

On my browser, Modernizr.audio.m4a is "maybe" (true), while Modernizr.audio.mp4 is "undefined" (false).

Refer to the documentation for more details.

1
  • Great, thanks Wander. I wasn't getting the "Maybe" response as well, so thanks for clarifying that. And yes, I had entered incorrectly as mp4 instead of m4a. Jun 2, 2014 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.