[SOLVED] Stop music from playing in next scene

So I am adding music, and everything I have tried failed to make the music stop when I move to the next scene, so the music keeps playing over and over on top of each other, how can I start it in one scene and stop it in the next?

Things I have tried:
-play music on channel function, then in the next scene stop all music in that scene
-tried same this as above only using “sound” functions instead of music
-there is no simple stop music function(like choose a specific music file to stop playing)
tried to test if I made it so it played only when a key was pressed so basically I could set it depending on if something was true(like an object was visible), but it just crashed my browser…
-Originally I had it set to play on scene start, but it carried over to next scene

I think that is everything I tried…

try it wit global variables.
-When global variable “music” is 0 (trigger once) → play music
-When global variable “music” is 1 (trigger once) → stop music

And change global variable when you want to music stop or play .

Right click the scene in the project manager on the left, click Edit the properties, and make sure “Stop all sounds and musics at startup” is enabled. That should do exactly as it says: stop all sounds and music when that scene gets loaded, before it starts playing sounds and music for that scene.

1 Like

what you are saying should work but there is no simple stop music, there is an option to stop music of a channel, but the channels music is not a global value (I assume so since I have tried plying on channels and stopping music of other channels when the scene starts) so I cant use the channels…

It is already set to stop all music, so idk why that is not working, maybe it is a bug in the program that is causing this to break? Maybe this should be a post in the bug reports section?

Are you working with native or HTML5?
Are you using “Play a music” or “Play a music on a channel” to start the music?

It works perfectly for me in native using “Play a music” and “Stop all sounds and musics at startup” in the scene properties, but I haven’t really done anything with sound in HTML5. If you want to stop the music at the end of a scene instead of at the start of another scene, you might need to use “Play a music on a channel” at the beginning and “Stop the music on a channel” before scene switching.

At the beginning of the scene :
Play a music on a channel

On scene switching action :
Stop the music on a channel
Change the scene

EDIT: In that order. Actions are processed in the order they are placed, so if you have Change the scene above Stop the music on a channel, it’ll probably change scenes before it gets to the change the Stop the music action.

Well it works for me in HTML5.

Thanks to all who have posted, but I guess it was just a bug, because when I reinstalled GDevelop it fixed the problem. :smiley:

Yeah! :sunglasses:

Your guide helped me a lot, thanks!
free ringtones