【发布时间】:2015-03-03 19:03:32
【问题描述】:
我正在尝试使用 AVFoundation 在用户处于锁定屏幕或他们在使用我的应用程序的过程中锁定应用程序时播放音频
class ViewController: UIViewController, AVAudioPlayerDelegate {
var avPlayer: AVAudioPlayer?
var error: NSError?
... other stuff ...
func playChime(fileName: String) -> Void {
let fileURL: NSURL! = NSBundle.mainBundle().URLForResource(fileName, withExtension: "wav")
self.avPlayer = AVAudioPlayer(contentsOfURL: fileURL, error: nil)
self.avPlayer?.play()
}
... other stuff ...
}
需要添加什么来确保用户在锁定屏幕上时也能播放声音?
【问题讨论】:
-
类似情况,但在 Objective-C 中:stackoverflow.com/questions/7619794/…
标签: swift ios8 avfoundation