来自firebase数据库的音频播放
我只需要下载,当它播放一些可以帮助我时
override func viewDidLoad() {
super.viewDidLoad()
let storageRef = storage.reference()
//getting a reference to the node artists
refPlaces = Database.database().reference().child("places")
//let storageRef = FIRStorage.storage().reference()
let files = storageRef.child("\(self.place?.ayah!)")
let localURL: NSURL! = NSURL(fileURLWithPath:"/Users/wayne/Desktop/Playground/Audio/Self Commitment.mp3")
let downloadTask = files.write(toFile: localURL as URL) { (URL, error) -> Void in
if (error != nil) {
print("Uh-oh, an error occurred!")
} else {
print("Local file URL for is returned")
}
}
let audioPath = localURL
do {
self.lbl1.text = place?.name!
try audioPlayer = AVAudioPlayer(contentsOf:URL(fileURLWithPath: (audioPath?.absoluteString)!))
self.audioPlayer.delegate = self
self.audioPlayer.play()
} catch {print("file is unavilable")
}
//audioPlayer.play()
print("Playing")
}
**当我运行播放页面时,它会给我错误