Home > Article > Web Front-end > HTML5 plug-in-free multimedia Media-detailed introduction to audio and video
Audio and video have become more and more popular now
In order to ensure cross-browser compatibility
, various websites still choose to use flash
(Source code intercepted from Youku)
HTML5 adds two multimedia tags, audio and video.
The compatibility is pretty good, but lower versions of IE do not support it
Yes It allows us to insert audio and video controls without using any browser plug-ins
and it is very simple
(source code taken from Bilibili) The usage of the
element is as follows:
<audio src="media/xi-Halcyon.mp3" id="demoAudio">不支持H5-audio</audio> <video src="media/Animation.mp4" id="demoVideo">不支持H5-video</video>
If the content in the tag is not supported by the browser, it will be displayed.
Of course, when using these two elements,
at least add the src attribute , the attribute value is the URL of the resource
But each browser supports different media formats due to copyright issues
So you can use the following method
<audio id="demoAudio"> <source src="media/xi-Halcyon.mp3"> <source src="media/xi-Halcyon.ogg"> ... 不支持H5-audio </audio> <video id="demoVideo"> <source src="media/Animation.mp4"> <source src="media/Animation.webm"> ... 不支持H5-video </video>
to specify different resource formats
Also ensures the compatibility of various browsers
In addition to src, the audio and video tags also have some public attributes
Description | |
---|---|
After setting this attribute, the audio/video resource is ready Play immediately | |
After setting this property, the browser playback control controls will be displayed | |
After setting this attribute, the audio/video will loop and start playing again after it ends | |
After setting this attribute, the audio/video will be played when the page is loaded Load and prepare to play (using autoplay will ignore this attribute) |
The above is the detailed content of HTML5 plug-in-free multimedia Media-detailed introduction to audio and video. For more information, please follow other related articles on the PHP Chinese website!