Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM Audio canPlayType() Method

Improve Article
Save Article
  • Last Updated : 14 Apr, 2021
Improve Article
Save Article

The Audio canPlayType() method is used for checking if the browser can play the specified audio type or not.
Return: The Audio canPlayType() method generally returns one of the following values: 

  • “probably”: It means that this audio type is most likely supported for browser.
  • “maybe”: It means that the browser might support this audio type.
  • “” (empty string): It means that the browser does not support this audio type.





<!DOCTYPE html>
        DOM Audio canPlayType( ) Method
<body style="text-align: center">
    <h1 style="color: green">
    <h2 style="font-family: Impact">
    Audio canPlayType() Method
        Does the browser support playing OGG audios? <span>
<button ondblclick=
        "My_Audio(event, 'audio/ogg', 'vorbis')"
<p>Does the browser support playing OGG audios? <span>
<button ondblclick=
        "My_Audio(event, 'audio/ogg', 'vorbis')"
        function My_Audio(e, vidType, codType) {
            var v = document.createElement("Video");
            isSupp =
                v.canPlayType(vidType + ';codecs="' + codType + '"');
            if (isSupp == "") {
                isSupp = "No";
                "Compatilibility : " + isSupp;



Supported Browsers: 

  • Chrome
  • Mozilla Firefox
  • Internet Explorer 9.0
  • Opera
  • Safari


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!