How do I Save and Load the Music?

How do I Save and Load the Music?

What is the expected result

The Music and SFX will save the sliders and the volume of the sound effects and music

What is the actual result

The SFX volume slider works fine, but not on Music. How can I fix this issue?

Related screenshots

Im ONLY looking for music, not the SFX one. Can you compare my event from yours?

Can you compare your events to mine?

this might sound crazy, and its just a tad off topic, but i dont understand the use of the music action? all it does is add an HTML element to play the music. and when i use the sound one instead, it just fixes all of the issues the music action has, and…with personally, no visible changes in what its doing.

Its been so long since I made a game. How can i compare it?

you use your eyes i think and look between both projects. you could also take a screenshot of one

Go to my tutorial and look at pictures of my events and compare them with picture of your events

It could be bc it’s playing the music at the beginning before the variable is loaded from storage. It uses the variable default value. Try moving the play event after the storage load events.

like this?

Does it work? The load part needs a trigger once like the at the beginning condition. Otherwise, it will keep trying to load it.

Before the music was being played before the volume was set. Does this work?

It does not work, the sliders doesnt move anymore when I try to drag them.

That’s because the load function is being triggered on each frame. Try putting the at the beginning condition on the load event.

So. If I replace all actions from “Music” to “Sounds” from all the music or it depends on the file size and duriation?

Look you ask to check your events did you do it right
But that is something you could do
Its not like it require any knowledge it just require checking if A on my screenshot = A on your screenshot
If B on your screenshot = B on my screenshot

Look beginning of scene cannot happen twice so it already works as trigger once so this trigger once is (NOT WRONG BUT) not needed

Keith told you what you did wrong KINDA
Gdevelop literally read all your logic from top to bottom
So everything needs to happen in some order

1 - Play your music but with what volume?
Well default to what you set your global var in variable window

2 - NOW you load your values
So to what you saved your music volume is now set
After you already play your music
Its like i 1st give you pepsi and you drink it
And now i bring you pizza
And you gonna now eat pizza without drink

3 - You set in 2 slider value to variable values
But you do not set volume on channel 1 (on which you play music)
To value of slider
So how your game could know to what volume change it?

And yes generally you should not use play music

Play sound on channel action to play music
Play sound action to play sounds

This way you cannot change volume of sounds midway AFTER they start playing and they auto play with whatever your variable for sound is

Where you can totally change volume on channel while sound on channel is playing

I don’t remember why we have play MUSIC action
It was something like better for streaming/playing large files
BUT 99% of user never gonna need it but its there in case someone will need

  1. The volume is based of the gloval variable called Options, it has 2 structures that are sfx and music. Both of them are set to 50.
    I did the sounds on channel to the music, just in case.

  2. Can you be more specific about it?

  3. Are you talking about this?

It worked somehow, but unlike sounds, the slider of the music didnt save the settings.
Is there something I missed?

Going from top to bottom
And i mean here when you look on your events sheet
In what order FROM TOP going down you should place your events

1st you load variable from storage
And below it you change slider value to that variable
You cannot 1st set slider to variable and then load variable
Cause you are most likely also saving variable below so you are overwriting what you wanted to do

In my guide there is whole section to saving and loading audio

I didnt realize that I could have done subevent by playing the music and putting it below the save system tihs whole time.
Thank you so much!