Javascript examples for DOM HTML Element:Audio
The canPlayType() method checks if the browser can play the specified audio type.
The canPlayType() method can return one of the following values:
Value | Description |
---|---|
type | audio type and optional codecs to test support for. |
Common values for type:
Common values, including codecs:
A String, representing the level of support.
Possible return values:
The following code shows how to Check if your browser can play different types of audio:
<!DOCTYPE html> <html> <body> <button onclick="supportType(event,'audio/ogg','vorbis')" type="button">Test</button> </span></p> <script> function supportType(e,vidType,codType) { var x = document.createElement("AUDIO"); isSupp = x.canPlayType(vidType+';codecs="'+codType+'"'); if (isSupp == "") { isSupp = "No"; }/*from www . j a v a2 s.c om*/ e.target.parentNode.innerHTML = "Answer: " + isSupp; } </script> </body> </html>