HTML5 audio


As HTML5 introduced audio support, you no longer need to use flash plugins to play audio. HTML5 audio element lets you play audio files. At this moment not all of browsers support HTML5 audio, so it is a good thing to have a backup solution for those clients with an old, or non HTML5 audio supporting browsers.

In order to use HTML5 audio tag, you can use following snippet:

<audio controls="controls" autoplay="autoplay">
	<source src="sound.ogg" />
	<source src="sound.mp3" />

Other problems with browsers supporting HTML5 audio are about format of audio files. Firefox supports an .ogg file, while Webkit browsers support .mp3 files. Opera on the other hand supports only .wav audio files. This won’t stop you from creating two files and naming them as a choice for HTML5 audio. If browser supports both file types – it will play just a first one.