Audio Control

Get help using Construct 2

Post » Sat Jan 20, 2018 5:35 pm

Hey guys.
I'm trying to figure out how to have a slider bar control audio that has been already playing from another layout. I've gotten the slider bar to adjust audio levels when the layout with the slider bar is playing music. Now I want the opening titles layout to play music, then allow the slider bar to have control of that audio without having to restart the entire song on the opening of the layout with the slider bar. I don't know if that makes sense to anyone else, but if it does, much help would be appreciated!
"It's a lobster fest by the end of the day." - J!NX 2017
B
22
S
5
G
2
Posts: 14
Reputation: 2,460

Post » Sun Jan 21, 2018 3:36 am

Add a tag "music" to your music playback. Change your event to this:

Audio Tag "music" is NOT playing -> Audio play "MyMusic.mp3" with tag "music"

What do you want to control will this slide bar - music volume?

On slidebar change -> Audio set "music" volume to slidebar.value


Here is how you properly change audio volume:
viewtopic.php?f=147&t=196411
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,401
Reputation: 84,429

Post » Mon Jan 22, 2018 11:15 pm

@dop2000 Thanks, but what I'm trying to figure out is kind of how to control audio that begins playing at the titles of the game. So basically, if you were to start up a game with music that plays at the titles and continues into the menu, and you wanted to lower that audio from the settings tab without the audio restarting on the opening of the settings tab, what would the code be to do that?
"It's a lobster fest by the end of the day." - J!NX 2017
B
22
S
5
G
2
Posts: 14
Reputation: 2,460

Post » Tue Jan 23, 2018 1:50 am

In the Title layout:

On Start of layout
...Audio Tag "music" is NOT playing -> Audio play "MyMusic.mp3" with tag "music"


In Settings layout:
On slidebar change -> Audio set "music" volume to slidebar.value
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,401
Reputation: 84,429

Post » Tue Jan 23, 2018 3:46 am

@dop2000 holy heck, that worked! Thanks so much, I truly appreciate it!
Actually, one more question: whenever I exit the settings layout then enter it again, the slider bar resets it's position, but not the volume level. Is it possible to set the volume with the slider, then have the slider save it's position upon exit and re-entry of the layout?
"It's a lobster fest by the end of the day." - J!NX 2017
B
22
S
5
G
2
Posts: 14
Reputation: 2,460

Post » Tue Jan 23, 2018 5:16 am

See the link I posted earlier, it has correct formulas for setting volume from the slidebar, and slidebar position from volume.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,401
Reputation: 84,429


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests