I've been working with the new SKAudioNode because the previous method of playing short audio with SKAction.playSoundFileNamed() was causing memory leaks on iOS9 (which seems to be already documented on these forums).
let audio = SKAudioNode(fileNamed: fileName)
audio.autoplayLooped = false
node.addChild(audio)
let action = SKAction.runBlock({ () -> Void in
let play = SKAction.play()
audio.runAction(play)
})
return action
Above is the snippet of code where I instantiate my SKAudioNode. The audio plays fine but when I plug/unplug earphones and try to play the audio, my app crashes and I get this error:
2016-01-31 01:58:40.485 dash[4860:1360578] 01:58:40.485 ERROR: [0x19fc2d000] AVAudioPlayerNode.mm:333: Start: required condition is false: _engine->IsRunning()
2016-01-31 01:58:40.486 dash[4860:1360578] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: _engine->IsRunning()'
This happens everytime I plug or unplug earphones and then try to play a sound with SKAudioNode.
Help greatly appreciated.