Reputation: 23
I playing the music in background with Third party Music Player, then I run this code in Xcode8, ios10. It work well.
let sceneView = SCNView(frame: self.view.bounds)
self.view.addSubview(sceneView)
let scene = SCNScene()
sceneView.scene = scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)
sceneView.allowsCameraControl = true
sceneView.showsStatistics = true
But when I click the home button, my app will crash and I get this error: "Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error 561015905'".
I don't know how to fix it.
Upvotes: 2
Views: 180
Reputation: 1287
I've resolved the exact same issue with
try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)
Upvotes: 0
Reputation: 5436
561015905 stands for the error AVAudioSessionErrorCodeCannotStartPlaying. Apple Docs gives the detail of this error as: "The app is not allowed to start recording and/or playing, usually because of a lack of audio key in its Info.plist. This could also happen if the app has this key but uses a category that can't record and/or play in the background (AVAudioSessionCategoryAmbient, AVAudioSessionCategorySoloAmbient, etc.)." I am also getting the same crash when using lock button in an app that uses SceneKit but doesn't use the audio.(From Comment of DancOfDeth here: What is Core Audio error 561015905 and why does it happen when I use the lock button?)
It looks like a bug, see the bug report related to that at below link:
https://openradar.appspot.com/28455923-SceneKit/CoreAudio Crash when device is locked
Upvotes: 1
Reputation: 13462
Looks like a SceneKit bug.
What you can try it to simply access scene.audioEngine
in order to warm up the audio engine (even if your app doesn't use audio).
Upvotes: 1