📅  最后修改于: 2022-03-11 15:01:01.584000             🧑  作者: Mango
guard let soundFileURL = Bundle.main.url(forResource: "TestSound",
withExtension:"wav") else {
print("URL not found")
return
}
do {
audioPlayer = try AVAudioPlayer(contentsOf: soundFileURL)
} catch let error {
print("Failed to load the sound: \(error)")
}
audioPlayer?.prepareToPlay()