码迷,mamicode.com
首页 > Web开发 > 详细

JS检测浏览器是否支持HTML5视频播放 (标签<video>) ,

时间:2015-07-27 18:14:33      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

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(‘video/mp4; codecs="avc1.42E01E, mp4a.40.2"‘);
            if (!h264Test) {
                document.getElementById("checkVideoResult").innerHTML = "Sorry. No video support.";
            } else {
                if (h264Test == "probably") {
                    document.getElementById("checkVideoResult").innerHTML = "Yes! Full support!";
                } else {
                    document.getElementById("checkVideoResult").innerHTML = "Well. Some support.";
                }
            }
        } else {
            if (oggTest == "probably") {
                document.getElementById("checkVideoResult").innerHTML = "Yes! Full support!";
            } else {
                document.getElementById("checkVideoResult").innerHTML = "Well. Some support.";
            }
        }
    } else {
        document.getElementById("checkVideoResult").innerHTML = "Sorry. No video support.";
    }
}

 

JS检测浏览器是否支持HTML5视频播放 (标签<video>) ,

标签:

原文地址:http://www.cnblogs.com/jinimy/p/4680803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!