I set up my Main Menu and Game Over Menu to use Background Music @1 and my Levels to use Background Music #2. When I transition to Game Over the levels music continues playing along with the Game Over music. And… sometimes the same thing happens when I choose Main Menu from the pause screen.
It’s playing “double music” on the Main/Game Over Menus after I transition from level 1 to level 2. I suspect I need to do something with the cleanupScene(), but backgroundMusicPlayer.stop() isn’t solving it.
I’m also thinking of doing something to stop the levels background music in my Home.swift didMoveToView just not sure the best thing to do… or if it would even solve the problem.
You might want to try what I do with the kits which is call NSNotifications up to the GameViewController, which is where the only AVAudioPlayer resides. I think one of the reason I started doing that was related to what you’re dealing with now. The other was you could loop an audio track between transitions. So if you wanted the same song playing between scenes, that would support it.
If you download any of the kits, do a quick search for NSNotification and you’ll see what’s going on. The post notification line sends a Dictionary up to the GameViewController with the filename of what to play (and in some of the kits there might be a little more info sent, like volume).
If you need some line by line notes, I can help there too.