Copy codeThe Code is as follows:
// 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 ){
Hsf-test = vidTest. canPlayType ('video/mp4; codecs = "avc1.42E01E, mp4a. 40.2 "');
If (! Hsf-test ){
Return false;
}
Else {
If (hsf-test = "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 supports playing in MP4 format (because Firefox does not support H. 264 encoded MP4 format). If true is returned, you can use the Video in HTML5 to play the Video. If false is returned, the Flash plug-in is used to play the Video.
This method is generally used for video websites, mobile phones, tablets, and other devices for video screen playback, mainly to be compatible with IOS;