Playing audio files

The audio element enables a simple way to play audio files in the browser. Adoption of this element had many controversial discussions mostly due to the lack of common grounds for a format. Initially Ogg Vorbis (http://www.vorbis.com/) was the format suggested in the W3C specification.

Note

Up-to-date information on browser support for different formats can be found on www.caniuse.com.

In this recipe, we will take a look at the element and some of the basic attributes that can be applied on it.

Getting ready

In order to play an audio we need an actual audio file. You can pick one on your own or use the one that comes with the example. The file will be served from the music folder. We will use Mozart—Clarinet Concerto in A K. 622, ...

Get HTML5 Data and Services Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.