Играть в звук в Swift 5
import AVFoundation
var player: AVAudioPlayer?
func playSound() {
guard let path = Bundle.main.path(forResource: "beep", ofType:"mp3") else {
return }
let url = URL(fileURLWithPath: path)
do {
player = try AVAudioPlayer(contentsOf: url)
player?.play()
} catch let error {
print(error.localizedDescription)
}
}
Gilles Ashley