HTML and CSS Reference
value is "" . If that is the case, the code that has called this function might need to be written
in a way to catch that condition and alter the program execution. We did that with the test of
the return value and the alert() message, which we described in the previous section.
If you want to test the error condition with no valid return value from this function, simply add an
extra character to the MIME type (for example, audio / oggx ) to make sure an empty string is always
Alternatively, you can use Modernizr to test for audio support. If you have included the
have written thus far), you can access the static values of Modernizr.audio.ogg , Modern-
izr.audio.wav ,and Modernizr.audio.mp3 totesttoseewhetherthosetypesarevalid.Theseare
not Booleans—they evaluate to the same probably , maybe , and "" values that we get from
a call to canPlayType() . If you are comfortable using Modernizr for all your tests, you can
replace the test in the code with tests of these Modernizr static values.