HTML5 Audio Exercise

Write HTML code to embed the following audio in your web document.

Suppose the audio source is -
http://www.etutorialspoint.com/images/papa_telefon.mp3

Solution

HTML5 provides audio element to embed audio in web page. Prior to HTML5, we are using third party plug-ins, like - Flash, Window Media Center, Apple iTunes, etc to play audio on the browser. The problem with these plug-ins are that, not all browsers or devices support it. HTML5 provides a standard way to include audio with several attributes which improve its default behavior.

This is the following HTML5 code to embed the given audio -

<audio controls="controls">
	<source src="audio/audio.mp3" type="audio/mpeg" />
	<source src="audio/audio.wav" type="audio/wav" />
	<source src="audio/audio.ogg" type="audio/ogg" />	
	Your browser does not support the embedded HTML5 audio element.
</audio>

Output of the above code

In the above code, controls specify audio control units like Play, Pause, Volume controls, the source contains different types of audio formats to support in different browsers and devices.



Read more articles


General Knowledge



Learn Popular Language