【发布时间】:2017-07-03 08:54:19
【问题描述】:
我已经直接在firebase Storage中上传了一些歌曲,我只想在AVAudioPlayer中播放歌曲。 以下是我正在尝试的代码:
var mainRef: FIRStorageReference {
return FIRStorage.storage().reference(forURL: "gs://musicapp-d840c.appspot.com")
}
var audioStorageRef: FIRStorageReference{
return mainRef.child("SongsPath")
}
audioStorageRef.downloadURL { url, error in
if let error = error {
print(error.localizedDescription)
} else {
if let url = url {
do {
self.audioPlayer = try AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: String(describing: url)) as URL)
self.audioPlayer.play()
} catch {}
let storyboard = UIStoryboard(name: "AudioPlayer", bundle: nil)
let audioVc = storyboard.instantiateViewController(withIdentifier: "AudioPlayerViewController") as! AudioPlayerViewController
audioVc.playThisSong = String(describing: url)
self.present(audioVc, animated: false, completion: nil)
}
}
}
这里来自firebase 的歌曲网址正在传递,但它正在跳过self.audioPlayer.play。 ,我只想流式传输音频。我可以为此找到适当的解决方案吗?
【问题讨论】:
标签: ios swift firebase firebase-storage