用JavaScript檢測視頻格式支持


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用JavaScript檢測視頻格式支持</title>
    <script type="text/javascript">
        function checkVideo() {
            var myVideo = document.createElement('video');
            if (myVideo.canPlayType) {
                if ("" != myVideo.canPlayType('video/mp4;codecs="avc1.64001E"')) {
                    document.write("您的瀏覽器支持h264編碼。<br>");
                }
                if ("" != myVideo.canPlayType('video/ogg; codecs="vp8"')) {
                    document.write("您的瀏覽器支持vp8編碼。<br>");
                }
                if ("" != myVideo.canPlayType('video/ogg; codecs="theora"')) {
                    document.write("您的瀏覽器支持theora編碼。");
                }
            }
            else {
                document.write("您的瀏覽器不支持要檢測的視頻格式。");
            }
        }
        window.onload = function () {
            checkVideo();
        }
    </script>
</head>
<body>
</body>
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM