Monday, 4 August 2014

How to add Audio in HTML 5


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>

Output


NOTE: Click on play botton to play audio in Output

HTML 5 MIME Types for Audio Formats

FormatMIME-type
MP3audio/mpeg
Wavaudio/wav
Oggaudio/ogg

HTML 5 Audio Formats and Browser Support

BrowserVersionsMP3WavOgg


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:
AttributeDescription
autoplaySpecifies that the audio will start playing as soon as it is ready.
autobufferThis boolean attribute if specified, the audio will automatically begin buffering even if it's not set to automatically play.
controlsIf this attribute is present, it will allow the user to control audio playback, including volume, seeking, and pause/resume playback.
loopThis boolean attribute if specified, will allow audio automatically seek back to the start after reaching at the end.
preloadThis attribute specifies that the audio will be loaded at page load, and ready to run. Ignored if autoplay is present.
srcThe URL of the audio to embed. This is optional; you may instead use theelement within the video block to specify the video to embed

No comments:

Post a Comment