O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

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

Volume and sustain controls

Let's add some controls to our piano to allow the user to change the volume and sustain. As you may recall, the volume of an audio element may be set to any value from 0 to 1.0. We will use a range input control that allows the user to control that via a slider.

The sustain control allows a note to remain playing after the piano key is released. When sustain is turned off, the note will stop playing as soon as the key is released. We will add a checkbox to turn this off and on.

You can find the source code for this section in chapter6/example6.3.

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