How to lower a computer's volume with a slider

How could you lower or higher the computer’s volume with a slider?

Changing the Volume of a user’s device directly isn’t possible like I know. Instead I would use Jovanny’s Sound API to manage the Volume of every Sound directly when it’s played.
You would need a slider which needs to have a value from 0 (muted) to 1 (max volume) and saves it to a global variable like window.VOL. This global variable you can now use to set the Volume of every sound with Jovanny’s Sound API.

Hope I could help!

1 Like

I agree with Towim, Jovanny’s Sound API is great for working with sounds!

And although there isn’t a way to change the volume of the computer that I know of, there is an easy way to change the volume of all sounds in a wick project to a specific value

This might help with your project

1 Like

How could you use this piece of code with a slider, is there a way?

1 Like

Try it… just make your own slider…

[1]. Make a slider clip and call it sliderClip. Like a vertical rectangle so the user can drag it.
[2]. Then inside of sliderClip, place the left corner of the rectangle to zero in x coordinate.
[3] Limit the user to move the slider from zero to a max number in x coordinate. (example from 0 to 200px)

Then on your Howler:

let userVolume = sliderClip.x / 200;
Howler.volume(userVolume);

That will set userVolume from 0 to 1, which are the min and max inputs for Howler vollumes.

3 Likes

I’d like to add that there’s also a built-in “slider” asset with the built-in assets in the editor.
It uses a similar method to the one Jovanny mentioned.

(I’d recommend trying to go through Jovanny’s steps for making a slider first for extra coding practice)


I was able to make a quick simple example with it:
My Project5-15-2022_15-39-17.wick (123.1 KB)

2 Likes

Thank you both for your help! :)