Using the Slider to control Sound volume


#1

This post will describe how to use the Slider component to control the volume of your Sound component. This will be demonstrated within a simple music player app.

The Layout Screen of this app has:

Two buttons, called Play and Stop

A Slider

A Sound component

Set the Slider to have a Maximum value of 100 and a Minimum value of 0. A step of 1 will give your slider a smooth effect, while larger steps will provide more discrete values for the user.

Set the initial volume of the Sound component to the same number as the initial value of the Slider. In this app they have both been set to 50.

The blocks for the Slider are very simple.

The Sound component can have a Volume value between 0 and 100.

When the value of the Slider changes, set the volume of the Sound component to the value of the Slider.

Here is an app that demonstrates this function.