Although the browser development is very fast, but the standard in the browser is still imperfect, in the previous development of HTML4+CSS2+JS to let many programmers headaches is browser compatibility problem, audio playback is the same, until now, there is still no web page to play video and audio standards. Now, in most browsers, audio is played through Plug-ins (such as Flash plug-ins). However, not all browsers have such plug-ins, so the audio playback caused a certain amount of trouble. In HTML5 's new standard, a standard way to include audio through the audio element is provided, so let's take a look at the tag in more detail.
First, support for the audio format
Currently, the audio element supports three audio formats
|
IE 9 |
Firefox 3.5 |
Opera 10.5 |
Chrome 3.0 |
Safari 3.0 |
Ogg Vorbis |
|
√ |
√ |
√ |
|
MP3 |
√ |
|
|
√ |
√ |
Wav |
|
√ |
√ |
|
√ |
Second, how to use
<! DOCTYPE html> Third, the audio label properties
Property |
value |
Description |
AutoPlay |
AutoPlay |
If this property appears, the audio plays immediately after it is ready. |
Controls |
Controls |
If this property appears, the control is displayed to the user, such as the play button. |
Loop |
Loop |
If this property occurs, the playback starts again whenever the audio is finished. |
Preload |
Preload |
If this property occurs, the audio is loaded when the page loads and is ready to play. If "autoplay" is used, the property is ignored. |
Src |
Url |
The URL of the audio to play. |