【发布时间】:2016-11-22 09:50:49
【问题描述】:
我在 SpriteKit 游戏中遇到了 AVAudioEngine 的问题 - 插入/拔出耳机时引擎停止并且当下一个声音播放时应用程序崩溃。这是一个已知的错误(或功能?) - 建议修复它 - 使用通知中心,AVAudioEngine 应该在更改其状态时发布通知。我已经制作了这段代码:
let notificationName = Notification.Name("AVAudioEngineConfigurationChange")
NotificationCenter.default.addObserver(self, selector: #selector(self.restartEngine(notification:)), name: notificationName, object: nil)
当我这样做时:
NotificationCenter.default.post(name: notificationName, object: nil)
我的选择器被调用。但是,当我插入/拔出耳机时 - 没有任何反应。斯威夫特 3、xcode 8、iOS 9.3 关于如何修复它的任何建议?
【问题讨论】:
标签: ios notifications avaudioengine