Summary

In this chapter, we learned how to use the HTML5 audio element and API to add sounds to web applications. We saw how to load and cache audio files by creating a re-usable audio manager object. Then we used HTML5 audio to create a virtual piano application for playing the piano in a web page. We used keyboard events to allow the user to play the piano keys via the keyboard. We added controls to change the volume and sustain notes.

We covered the following concepts in this chapter:

  • How to add the HTML5 <audio> element to a web page and use its attributes to control it
  • Using the Audio API from JavaScript to programmatically control the playback of an audio element
  • How to load audio files and cache them for playback later
  • How to play, pause, and reset an audio file
  • How to hook up keyboard events to the document and handle them in our applications
  • How to change the volume of an audio element using a range input control
  • How to check if any HTML5 input type is supported by the browser

In the next chapter, we will take our piano application and turn it into a game called Piano Hero. We will learn about timing, animating elements, and playing back music by creating an audio sequencer.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.107.90