JS detects whether the browser supports the video label in HTML5

Source: Internet
Author: User

  This article mainly introduces the use of JS to detect whether the browser support HTML5 in the video label method, the need for friends can refer to the following

The code is as follows://Detect support for HTML5 function CheckVideo () {    if (!! Document.createelement (' video '). Canplaytype} {        var vidtest = document.createelement ("video" );         oggtest = Vidtest.canplaytype (' Video/ogg; codecs= "Theora, Vorbis");         if (!oggtest) {            h264test = Vidtest.canplaytype (' vide O/mp4; Codecs= "avc1.42e01e, mp4a.40.2");             if (!h264test) {                return False                         else {        & nbsp       if (h264test = "probably") {                    R Eturn true;                                 else {& nbsp                   return false;                            }                 else {            if (oggtest = "probably") {                return true;                         else {        & nbsp      return false;                     {   }     else {  &nbs P     return false;    }     Use the above method to determine whether the current browser supports the video label in HTML5 and can support playback using the MP4 format (because Firefox appears to be due to copyright Playback in the H.264 encoded MP4 format is not supported, if true, the video in HTML5 can be played and returned false, and the Flash plugin will be used to play it. This method is commonly used for video sites, compatible with mobile phones, tablets and other devices to play the video screen, mainly for the compatibility of iOS;  

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: info-contact@alibabacloud.com 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.