Home > Web Front-end > JS Tutorial > body text

How to use js to detect whether the browser supports the video tag in html5_javascript skills

WBOY
Release: 2016-05-16 16:55:39
Original
1057 people have browsed it

Copy code The 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) {
h264Test = vidTest.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
if (!h264Test) {
                                                                                                       return true;
}
else {
                     return false;                                                      == "probably") {
                 return true;
                                      ; 🎜>

Use the above method to determine whether the current browser supports the Video tag in HTML5 and can support playback in the MP4 format (because Firefox does not support playback in the H.264 encoded MP4 format due to copyright reasons). If If you return true, you can use Video in HTML5 to play the video; if you return false, you can use the Flash plug-in to play it.
This method is generally used on video websites and is compatible with mobile phones, tablets and other devices for video playback, mainly for compatibility with IOS;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template