I can't get this code to work, I keep getting an error saying:
Argument labels '(FileURLWithPath:)' do not match any available overloads
do {
audioPlayer = try
AVAudioPlayer(contentsOf:
URL(FileURLWithPath: sound!))
audioPlayer.prepareToPlay()
} catch {
print("error")
}
Do you have any suggestion?
The error Argument labels '(FileURLWithPath:)' do not match any available overloads
which is mentioned is quite remarkable.
Replace
AVAudioPlayer(contentsOf: URL(FileURLWithPath: sound!))
With
AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound!))