我的应用进入后台模式四分钟后,如何播放声音?
我尝试使用NSTimer,但是它在三分钟而不是四分钟后播放。
func applicationDidEnterBackground(application: UIApplication)
{
self.timer = NSTimer.scheduledTimerWithTimeInterval(240.0, target: self, selector: "createAVMIDIPlayer", userInfo: nil, repeats: false)
}
func createPlayer() {
if let soundURL = NSBundle.mainBundle().URLForResource("Text to Speech", withExtension: "m4a") {
var mySound: SystemSoundID = 0
AudioServicesCreateSystemSoundID(soundURL, &mySound)
AudioServicesPlaySystemSound(mySound);
}
}
最佳答案
通常,除非iOS应用在plist中设置了正确的背景模式功能,并且已经开始在前台播放音频(并且没有停止播放),否则它们无法在后台播放音频。
关于ios - 应用进入后台模式四分钟后播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35066797/