📅  最后修改于: 2022-03-11 15:00:59.299000             🧑  作者: Mango
import AVFoundation
var bombSoundEffect: AVAudioPlayer?
let path = Bundle.main.path(forResource: "example.mp3", ofType:nil)!
let url = URL(fileURLWithPath: path)
do {
bombSoundEffect = try AVAudioPlayer(contentsOf: url)
bombSoundEffect?.play()
} catch {
// couldn't load file :(
}