I am trying to play audio from firebase database. My code is successful at grabbing the correct audio url as a URL from Firebase Database but I am having trouble playing it. When the view controller is opened, no audio is playing. I have tried my AVAudioPlayer with sample music from my library it works fine but it is not playing the selected audio url at all. This is my code for my AVAudioPlayer where I am trying to pass in the URL for it to play.
do {
let songURL = url
print(songURL!)
try player = AVAudioPlayer(contentsOf: songURL!)
progressBar.maximumValue = Float(player.duration)
timer = Timer.scheduledTimer(timeInterval: 0.00001, target: self, selector: #selector(changeSliderValueFollowPlayerCurtime), userInfo: nil, repeats: true)
player.delegate = self
player.play()
}
the "url" in the line of code let songURL = url
comes from data passed from another tableview controller when the user selects the song it passes through information including the audio url from firebase database.