The code copy is as follows:
//Detect 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;
}
}
The above method can be used to determine whether the current browser supports the Video tag in HTML5 and can support playing using MP4 format (because Firefox seems to be not supported for MP4 format encoded by H.264). If true is returned, Then you can use Video in HTML5 to play video, return false, and use the Flash plug-in to play.
This method is generally used for video websites, compatible with mobile phones, tablets and other devices to play video, mainly for IOS compatibility;