HTML 5 Audio
we can put the Audio file in the webpage with the help of <Audio> Tag.HTML5 helpes to attech Audio file into a web page .
EXAMPLE
<!DOCTYPE html>
<html>
<body>
<audio controls><source src="music_file.ogg" type="audio/ogg">
<source src="music_file.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
<html>
<body>
<audio controls><source src="music_file.ogg" type="audio/ogg">
<source src="music_file.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
Output
NOTE: Click on play botton to play audio in Output
HTML 5 MIME Types for Audio Formats
| Format | MIME-type |
| MP3 | audio/mpeg |
| Wav | audio/wav |
| Ogg | audio/ogg |
HTML 5 Audio Formats and Browser Support
| Browser | Versions | MP3 | Wav | Ogg |
![]() | Chrome 6+ |
|
|
|
| Firefox 3.6+ | ![]() | ![]() | ![]() |
| Internet Explorer 9+ | ![]() | ![]() | ![]() |
| Opera 10+ | ![]() |
|
|
| Safari 5+ |
|
|
|
HTML 5 Audio Attribute Specification
The HTML5 audio tag can have a number of attributes to control the look and feel and various functionalities of the control:
| Attribute | Description |
| autoplay | Specifies that the audio will start playing as soon as it is ready. |
| autobuffer | This boolean attribute if specified, the audio will automatically begin buffering even if it's not set to automatically play. |
| controls | If this attribute is present, it will allow the user to control audio playback, including volume, seeking, and pause/resume playback. |
| loop | This boolean attribute if specified, will allow audio automatically seek back to the start after reaching at the end. |
| preload | This attribute specifies that the audio will be loaded at page load, and ready to run. Ignored if autoplay is present. |
| src | The URL of the audio to embed. This is optional; you may instead use the |













No comments:
Post a Comment