Use audio tags <audio>
The use of the audio tag is very similar to that of the Video: when multiple audio files are specified, the browser will play the first supported audio file.
1. <audio src = "audio.ogg" controls>
2. Your browser does not support <audio> labels.
3.
</Audio>
Figure 5All <audio> available attributes are listed. Because you do not need to display the entire control like a video player, the high, low, and preview charts (poster) are no longer needed.
Figure 5
Audio tag <audio> attributes
Attribute |
Value |
Description |
Autoplay |
Autoplay |
If specified, the audio will be played immediately after preparation. |
Controls |
Controls |
Display the playback control toolbar .. |
Loop |
Loop |
If this parameter is specified, loop playback is enabled. |
Preload |
Preload |
If specified, the audio will be loaded during page loading. When Autoplay is specified, it is ignored. |
SRC |
URL |
The URL of the target audio. |
Like the video tag, you can specify multiple files and the browser will play the first file supported. You can also specify a fallback information for display when the browser does not support the <audio> label. The following is a simple example:
1. <audio controls autoplay>
2. <source src = "audio1.ogg" type = "audio/Ogg"/>
3. <source src = "audio1.mp3" type = "audio/MPEG"/>
4. Your browser does not support <audio> labels.
5.
</Audio>
Summary
Currently, the biggest problem with HTML5 multimedia is that you must provide different formats of files for different browsers, but its application is also the trend of the times. The following are some great references:
- Http://www.w3.org/TR/html5/video.html
- Http://dev.w3.org/html5/spec/Overview.html
- Http://w3schools.com/html5/default.asp
- Http://html5test.com/
- Http://caniuse.com/
Reference: Learn about multimedia-video in HTML5)
Original article address: working with media in HTML5
Author: Jason beres
Reprinted please indicate the source: http://blog.csdn.net/horkychen