O'Reilly logo

HTML5 Multimedia Development Cookbook by Lee Jordan, Dale Cruse

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 with JavaScript

HTML5 introduces more flexibility in how audio files are used on the Internet. In this recipe, we will create a game to practice loading and playing sounds using the audio tag and JavaScript.

Getting ready

You will need an audio file to play, an image, and a modern browser that supports HTML5. The example files for this chapter can be downloaded from http://www.packtpub.com/support?nid=7940. The Free Sound Project (http://freesound.org) has audio files you can use as long as credit is given to the producer, and photos can be found at http://www.Morguefile.com for use in your personal projects.

How to do it...

Now we are ready to create a series of buttons and a short JavaScript program that will play a random ...

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