I'm getting this error message when I play a sound, error has always happened the first time you play the sound, in some tests the error does not appear and in other sim ..
var beep : AVAudioPlayer?
override func viewDidLoad() {
super.viewDidLoad()
if let beep = self.setupAudioPlayerWithFile("beep", type:"wav") {
self.beep = beep
}
//SOM
func setupAudioPlayerWithFile(file:NSString, type:NSString) -> AVAudioPlayer? {
let path = NSBundle.mainBundle().pathForResource(file as String, ofType: type as String)
let url = NSURL.fileURLWithPath(path!)
var audioPlayer:AVAudioPlayer?
do {
try audioPlayer = AVAudioPlayer(contentsOfURL: url)
} catch {
print("Player not available")
}
return audioPlayer
}
//Para tocar
beep?.play()