There are two ways to insert videos into HTML, one is the ancient object tag, and the other is the video tag in html5. The former has relatively better compatibility, while the latter has compatibility that is a headache. There are two most commonly used methods of inserting videos into HTML, one is the ancienttag, and the other is the
tag in HTML5.
The former has compatibility, but it is not very convenient to use. The latter is very convenient to use, but the compatibility is a headache.
Although there are many problems with the compatibility of the latter, because it is very convenient to use and conforms to the development trend of future web design, we use the latter as the main method of inserting videos. Because of its compatibility issues, the former is used as Auxiliary.
The example is as follows:
The code is as follows:
Currently, the video element supports three video formats:
Format IE Firefox Opera Chrome Safari
Ogg No 3.5+ 10.5+ 5.0+ No
MPEG 4 9.0+ No No 5.0+ 3.0+
WebM No 4.0+ 10.6+ 6.0+ No
Ogg = With Theora video encoding and Vorbis audio Encoded Ogg file
MPEG4 = MPEG 4 file with H.264 video encoding and AAC audio encoding
WebM = WebM file with VP8 video encoding and Vorbis audio encoding
Note: The format must comply with the above three detailed requirements, such as MPEG 4, which must be H.264 video and AAC audio.
In this case, if the video format is correct, we are quite satisfied with the compatibility results of most browsers, but IE678 does not support it, and their users are still a very large group in China. We You must think of another solution to support them:
The code is as follows:
This introduces some files, in addition to videos in flv format, there are also several swf or js files , are all generated using DW software. If you don’t want to study thetag, just go to DW software to generate it. If you can cleverly integrate the two pieces of code
, you can get compatible with all mainstream The ultimate browser code.
So we can do this:
Use jquery to determine whether the browser is IE (there is no need to determine the specific IE version, because the higher version of IE may not pass due to server reasons, for the time being, all IE will use < ;object>tag), load different tags according to the version, the code is as follows:
The code is as follows:
Don’t forget to introduce the jquery file before writing this code
At this point, you can write HTML video code that is compatible with all browsers.
For more related articles about inserting videos into HTML and being compatible with all browsers, please pay attention to the PHP Chinese website!