0

audio play from firebase database

i just need to download when it playing some one can help me please

 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")



}

**it's gives me error when i run the play page

enter image description here

0 Answers0