In this add-on, you will add music and a volume-control slider to your project.
The music will play when the play sprite is clicked, and the user will control the volumeby clicking the volume sprite.
To start, select the volume sprite.
You can add music from the Scratch library or from the CS First Music Library.
To add music from the Scratch library, select the sounds tab, click "choose sound from library,"and select a sound.
To add music from the CS First library, click the Music Library link on this page.
Listen to some of the different options.
When you find one you like, click download.
Then, in the Scratch tab, click “upload sound from file,” and select the file youjust downloaded.
When the play sprite is clicked, it broadcasts a message.
To make the volume sprite receive that message and start playing music, add a "when I receive"block, and select the “play” message from the dropdown menu.
Add a "play sound" block, and select the song you just picked from the dropdown menu.
That's pretty cool, but it would be even more impressive if the user could control the volumeof the music in the project.
To enable the user to adjust the volume by clicking the volume sprite, place a "set volume"block from the sounds menu under the "play sound" block.
Right now, the volume is set at 100%.
To enable the user to change the volume, select the data menu, and click "Make a variable."
Name the variable "volume."
Add the volume variable to the "set volume" block.
To make the volume slider show up when the user clicks the volume sprite, check the boxnext to the volume variable in the scripts menu, and double click the variable displayon the stage until the slider display shows up.
Move the slider next to the volume sprite on the stage.
Try it out!
Click the play sprite to start the music.
Adjust the volume using the slider.
The volume doesn’t change!.
When the volume sprite receives the play message, it sets the volume once.
To enable the user to adjust the volume at any point after the play message is received,place a forever loop around the "set volume" block to continually check the volume levelthe user has set.
Test it out.
Now it's your turn!
Add sound to your project, and add code that lets the user adjust the volume with a variable slider.
Choose an Add-On
Customize your video with different backdrops.
Create an exciting video opening.
Add other characters to support your cause.
Inspire with Music
Add uplifting music that will start when the play button is pressed.
Target Your Message
Change your message based on the user's response to a question.