How to use music audio to continue playing when entering levels (scene)?

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

I want to use my music audio to continue playing when entering level (scenes).
I want to command my music audio to stop playing like
Play(“Level1”) to Stop(“Level5”)
i know how to use AudioStreamPlayer but i don’t know how to code/commands it.
What code/commands should i use?

:bust_in_silhouette: Reply From: Diet Estus

You can create a singleton scene called Sound.tscn which contains all your AudioStreamPlayers. A singleton is a scene that is always present as a node of your game, regardless of whatever other nodes you load.

You can specify a scene as a singleton in your Project Settings.

Once you have the singleton, elsewhere in your code you can make calls like this:

Sound.get_node("Music1").play()

You can also create custom functions in a script on your Sound node which fade the music in and out, as well as transition between tracks.