2

Background music in my game works fine and plays behind other sounds that get activated. The back ground music is in Did Move to view and is a SKAudionode. When a call is received the background music stops and does not restart even if the home button is pressed and game restarted.

I have seen some other topics but they all seem to be related to AVAudioplayer which I have tried for background music but it gave me a different set of issues so I would prefer to use SKAudionode.

The code for the background music is below. Any help would be appreciated.

var backgroundMusic: SKAudioNode!

    override func didMove(to view: SKView) {
    if let musicURL = Bundle.main.url(forResource: "playlistbj", withExtension: "mp3") {
    backgroundMusic = SKAudioNode(url: musicURL)
        addChild(backgroundMusic)}

}
Joe
  • 23
  • 5
  • Is that something that you need to run with `SKScene`? I have a game where I run background. In this case, I control music through a view controller. – El Tomato Jul 08 '20 at 01:00
  • yes , it is in the class GameScene which inherits from : SKScene. – Joe Jul 08 '20 at 16:57
  • I have tried to use Audioplayer but the background music just stops when other sounds activate. – Joe Jul 08 '20 at 23:16
  • I managed to fix the issue with two sounds playing by creating an AVAudioplayer for each. I still cant get the background music to restart after a all interruption. – Joe Jul 10 '20 at 12:50

0 Answers0