HTML | DOM Video canPlayType( ) Method

The Video canPlayType() method is used for checking if the browser can play the specified video type or not. The Video canPlayType method returns a string which represents the level of support.



Parameter Values:

  • type : It specifies the video type (and optional codecs) to test support for.

Return: The Video canPlayType() method generally returns one of the following values:

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

Below program illustrates the Video canPlayType() method :

Example: Checking if a browser can play different types of video or not.





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



  • Before clicking the button:
  • After clicking the button:

Supported Browsers: The browser supported by HTML | DOM Video canPlayType( ) Method are listed below:

  • Google Chrome
  • Internet Explorer 9.0
  • Firefox
  • Opera
  • Apple Safari


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.