0
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 there is no error and in others yes..
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()
You can also enter a snippet of the code you are using to play the sound?
– Paulo Rodrigues
@Paulorodrigues added the code
– Fábio Reibnitz