I'm trying to load/play an audio file store in the assets library but for some reason it can not be found in the bundle.
func playAudio() {
let path = Bundle.main.path(forResource: "sound", ofType:nil)!
let url = URL(fileURLWithPath: path)
do {
sound = try AVAudioPlayer(contentsOf: url)
sound?.play()
} catch {
// do something
}
}
Any of you knows what I'm doing wrong? or why Xcode can not find the file?