HTML 5 Audio

There is no tag available in HTML previous version to add audio in the Webpage. The majority of audio available on Web pages using the flash plug-in which is also not supported by every browser. HTML introduce a new element <audio> to show audio on webpage without need of any plug-in.

Files format supported by <audio> in HTML 5

Following are the formats supported by the HTML 5 audio element are MP3, Wav and Ogg Voribs

In HTML 5 its very easy to show the audio on Web pages, the only thing you need to do is:

<audio src=”audio file name> </audio>

Multiple sources

Multiple sources can be define in <audio> element. The browser will start running the first recognized format if no format is supported then the message will be displayed on browser.

<audio width="500" height="500">
  <source src="music.ogg" type="audio/ogg" />
  <source src="music.mp3" type="audio/mp4" />
This browser not support audio tag 

</audio>

Attributes of <Video> in HTML 5

There are number of attributes which can be used in audio element such as:

Controls

<audio src=”abc.mp3controls=”controls> </audio>

To add play, pause and volume controls in the audio through which you have control over the audio.

Autoplay

<audio src=”abc.mp3autoplay=”autoplay><audio>

The audio will play automatically as soon as the page is completely loaded.

Loop

<audio src=”abc.mp3loop=”loop><audio>

The audio will start running automatically for the start as soon as it finished

Preload

<audio src=”abc.mp3preload=”preload><audio>

Audio is loaded with the page load, the attribute will be ignored if autoplay attribute is present.

Be Sociable, Share!

One response to HTML 5 Audio

Leave a Reply