Use js to detect whether the browser supports the video tag in html5
- 2020-03-30 02:20:35
- OfStack
//Check whether HTML5 is supported
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) {
return false;
}
else {
if (h264Test == "probably") {
return true;
}
else {
return false;
}
}
}
else {
if (oggTest == "probably") {
return true;
}
else {
return false;
}
}
}
else {
return false;
}
}