How to tell if the current browser supports HTML5 video tags

Source: Internet
Author: User

How to tell if the current browser supports HTML5 video tags:

HTML5 added a video tag for playing videos, the function is very powerful, but because of the current many browsers are not supported, so in the use of the need to determine whether the current browser support this tag, the following provides a piece of code to achieve this function, hoping to bring some help to the needs of friends.

The code is as follows:

//detects if HTML5 is supportedfunctionCheckVideo () {if(!! Document.createelement (' video '). Canplaytype) {varVidtest = document.createelement ("video"); Oggtest= Vidtest.canplaytype (' Video/ogg; codecs= "Theora, Vorbis" '); if(!oggtest) {H264test= Vidtest.canplaytype (' Video/mp4; codecs= "avc1.42e01e, mp4a.40.2" '); if(!h264test) {        return false; }      Else{        if(H264test = = "probably"){          return true; }        Else {          return false; }      }    }    Else{      if(Oggtest = = "probably"){        return true; }      Else{        return false; }    }  }  Else{    return false; }}

The original address is:

The most original address is:

How to tell if the current browser supports HTML5 video tags

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.