zoukankan      html  css  js  c++  java
  • 检测您的浏览器是否支持 HTML5 视频方法

    http://www.w3school.com.cn学习html5的时候,看到一个检测您的浏览器是否支持 HTML5 视频的方法:

    运行效果:

    1.在EditPlus中运行

    2.在chrome浏览器中运行

    =======================================================

    代码部分:

    =======================================================

     1 <!DUCTYPE HTML>
     2 <html>
     3 
     4 <script type="text/javascript"> 
     5 function checkVideo()
     6 {
     7 if(!!document.createElement('video').canPlayType)
     8   {
     9   var vidTest=document.createElement("video");
    10   oggTest=vidTest.canPlayType('video/ogg; codecs="theora, vorbis"');
    11   if (!oggTest)
    12     {
    13     h264Test=vidTest.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
    14     if (!h264Test)
    15       {
    16       document.getElementById("checkVideoResult").innerHTML="Sorry. No video support."
    17       }
    18     else
    19       {
    20       if (h264Test=="probably")
    21         {
    22         document.getElementById("checkVideoResult").innerHTML="Yes! Full support!";
    23         }
    24       else
    25         {
    26         document.getElementById("checkVideoResult").innerHTML="Well. Some support.";
    27         }
    28       }
    29     }
    30   else
    31     {
    32     if (oggTest=="probably")
    33       {
    34       document.getElementById("checkVideoResult").innerHTML="Yes! Full support!";
    35       }
    36     else
    37       {
    38       document.getElementById("checkVideoResult").innerHTML="Well. Some support.";
    39       }
    40     }
    41   }
    42 else
    43   {
    44   document.getElementById("checkVideoResult").innerHTML="Sorry. No video support."
    45   }
    46 }
    47 </script>
    48 
    49 <body>
    50 
    51 <p>检测您的浏览器是否支持 HTML5 视频:</p>
    52 
    53 <div id="checkVideoResult" style="margin:10px 0 0 0; border:0; padding:0;">
    54 <button onclick="checkVideo()" style="font-family:Arial, Helvetica, sans-serif;">Check</button>
    55 </div>
    56 
    57 </body>
    58 </html>
  • 相关阅读:
    VOIP开源项目源码地址(一)
    iptables下udp穿越实用篇
    function socket about http://net.pku.edu.cn/~yhf/linux_c/function/14.html
    IOKE的SIP协议专栏
    XviD core API overview: Decoding
    Socket about
    sql海量数据优化
    Socket、多线程、消息队列、共享资源并发下的性能研究
    【转】SQL 索引理解
    SQL 索引理解
  • 原文地址:https://www.cnblogs.com/hongten/p/hongten_html5_video.html
Copyright © 2011-2022 走看看