How to make singleton AudioStreamPlayer not play during a sene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Anastasia

I’ve gotten a singleton named music. How do I make so, during the scene named “Menu”.
During this scene I dont want the singleton to play. Its a loop btw
Any way to do that?

When is it suppose to play? Is it suppose to play once?

Ertain | 2020-01-10 19:38

Its suposed to loop in all of the other scenes, exept this one and a few more

Anastasia | 2020-01-11 15:17

If it’s not suppose to play for the “Menu” scene, then have the scene switching code tell the audio singleton which scene is going to be loaded. The audio singleton acts based upon which scene it is told.

To prevent it from looping (at least when you don’t want it to loop) use something like this:

if scene == "Menu":
   music.get_stream().set_loop(false)

Or more directly:

if scene == "Menu":
  music.stream.loop = false

Ertain | 2020-01-11 22:49

if scene is not a valid argument as far as I know

Anastasia | 2020-01-12 15:35