O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required