HTML5 Audio

So after going though previous chapters you may have familiar with a few elements of HTML5. Now we will try to learn about a most popular element of HTML5, AUDIO Element. It is the one of the best powerful weapon of HTML5.

<audio> .... </audio>

With the development of HTML5, AUDIO Element has been introduced for playing the audio file in the browser with full user control support. Yet, before the development of HTML5 AUDIO Element, we were unable to play a audio file without using the third party browsers plug-in as flash player or quick time. Now the AUDIO Element can be used instead of installing a browser plug-in. The AUIDO Element contains an extra child element is called SOURCE, which is used to call the exact media file which we want to be played in the browser. The AUDIO Element can also contains it's properties for controlling the AUDIO File.


Here is the Syntax for AUDIO Element

<audio>
<source src="Place your audio file here with full path" type="audio/mpeg"/>
<source src="Place your audio file here with full path" type="audio/ogg"/>
</audio> 



Below is complete syntax alogn with example


<html>
<head>
<title>Title Name will go here</title>
</head>
<body>
<audio controls>
<source src="media/simple_audio.mp3" type="audio/mpeg"/>
<source src="media/simple_audio.ogg" type="audio/ogg"/>
<!-- This Line Will Be Called When You Are Running An Old Browser -->
<p>Your file doesn't support the audio element</p>
</audio>
</body>
</html> 

No comments:

Post a Comment