In the HTML5 standard page, we are able to use the audio tag to complete our call and playback of the sound.
The following are the most commonly seen use of HTML5 three basic formats:
1. Minimal code
<audio src= "Song.ogg" controls= "Controls" ></audio>
2. Code with an incompatible reminder
<audio src= "Song.ogg" controls= "controls" >your browser does not support the audio tag.</audio>
3. Try to be compatible with the browser
<audio controls= "Controls" ><source src= "Song.ogg" type= "Audio/ogg" ><source src= "Song.mp3" type= " Audio/mpeg ">your Browser does not support the audio tag.</audio>
HTML5 Audio Format
Currently, the HTML5 audio tag supports three formats, each of which is WAV MP3 and ogg format.
And now the mainstream browser supports them such as the following:
|
IE 9 |
Firefox 3.5 |
Opera 10.5 |
Chrome 3.0 |
Safari 3.0 |
Ogg Vorbis |
|
√ |
√ |
√ |
|
MP3 |
√ |
|
|
√ |
√ |
Wav |
|
√ |
√ |
|
√ |
HTML5 audio tags are not supported under IE8 and IE8.
HTML 5 Audio Properties
- AutoPlay: The only selectable value is autoplay. When the AutoPlay attribute is present and the exact value is assigned, the audio will play itself actively
- CONTROLS: The only selectable value is controls. When the controls property is displayed and is accurately assigned, the audio playback controls will appear, including: Play, pause, position, volume, full screen toggle, subtitle (assuming available), audio track (assuming available).
- Loop: The only selectable value is loop. When the loop attribute is present and the exact value is assigned, the audio is looped back.
- Preload: The optional value is auto (load the entire audio when the page loads), meta (just load the metadata when the page loads) and none (when the page loads without audio) assuming that the preceding AutoPlay attribute is set, then preload will be ignored.
- SRC: Specifies the audio URL address. The ability to be a relative URL can also be an absolute URL, and of course, like the 2nd and 3rd examples, the source tag is used to specify the origin.
HTML 5 Audio