本文介绍了SKAudioNode崩溃:AVAudioPlayerNode.mm:333:开始:所需条件为假:_engine-> IsRunning()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的SKAudioNode:

I've a simple SKAudioNode:

let backgroundSound = SKAudioNode(fileNamed: "backgroundSound.mp3")

我曾经玩backgroundSound.runAction(SKAction.play()),而backgroundSound.runAction(SKAction.stop())停了.

一切正常,直到应用程序确实进入了后台模式,我将继续3分钟以上.如果我进入后台模式并在10到20秒后恢复播放,则音频不会崩溃.

Everything works fine until the app did enter in background mode and I'll resume more than 3 minute.If I go in background mode and resume after 10 - 20 seconds, the Audio doesn't crash.

所有崩溃日志:

2016-05-29 23:26:43.612 PippiPompiere[1070:199471] 23:26:43.611 ERROR:    [0x3a7cf000] AVAudioPlayerNode.mm:333: Start: required condition is false: _engine->IsRunning()
2016-05-29 23:26:43.616 PippiPompiere[1070:199471] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: _engine->IsRunning()'
*** First throw call stack:
(0x23ba5b8b 0x23362dff 0x23ba5a61 0x29499ea9 0x294e3739 0x294e2819 0x2fe98ee7 0x2ff16b43 0x2feb0363 0x2ff413e9 0x2feb03bb 0x2fec2cf1 0x2fee6dfd 0x2fee34fd 0x2fee2a05 0x2fee498b 0x2ff1705b 0x476ab1 0x2623d967 0x2623d7b7 0x25916513 0x23df75e5 0x23b53f3d 0x23b6821b 0x23b6792f 0x23b65d41 0x23ab4289 0x23ab407d 0x250d0af9 0x281df2c5 0x1230c8 0x23760873)
libc++abi.dylib: terminating with uncaught exception of type NSException

我还使用此通知来暂停所有场景广告停止SKAudioNode操作:

I use also this notification to pause all scene ad stop SKAudioNode action:

func applicationDidEnterBackground(application: UIApplication) {
        NSNotificationCenter.defaultCenter().postNotificationName(notificationPauseGame, object: nil)
    }

你有什么主意吗?

谢谢大家

推荐答案

您可以尝试通过以下方式加载文件:

You could try to load your file with:

var backgroundMusic: SKAudioNode!

if let musicURL = NSBundle.mainBundle().URLForResource("backgroundSound", withExtension: "mp3") {
    backgroundMusic = SKAudioNode(URL: musicURL)
    addChild(backgroundMusic)
}

此方法直接提供您的音频资源,而无需留给fileNamed在主捆绑中进行搜索,这是另一种选择.

This method give directly your audio resource without leave to fileNamed to search in main bundle , it's an alternative.

这篇关于SKAudioNode崩溃:AVAudioPlayerNode.mm:333:开始:所需条件为假:_engine-> IsRunning()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 20:08