How to download Video URLString from Firebase Database not Storage in Swift -
i have been looking everywhere how videos urlstring
out of firebase tree structure can’t find anywhere. seems showing how play directly firebase storage. have created urlstring
in tree node in firebase database points video in storage. i’m trying urlstring
of highlightvideo
tree.
here’s i’m code:
private func setupplayerview() { firdatabase.database().reference().child("users").child(firauth.auth()!.currentuser!.uid).observeeventtype(.childadded, withblock: { (snapshot) in guard let dictionary = snapshot.value as? [string: string] else { return} let urlstring = dictionary["highlightvideo"] }, withcancelblock: nil) if let url = nsurl(string: urlstring) { ---code breaks on urlstring player = avplayer(url: url) let playerlayer = avplayerlayer(player: player) videoview.layer.addsublayer(playerlayer) playerlayer.frame = cgrect(x: 0, y: 0, width: frame.width, height: frame.width * (9/16)) player?.play() }}
i have feeling issue here video not in correct format (needs h.264 or mpeg-4 in .mp4
, .m4v
, .mov
[or hls video live streaming]), , content type should set appropriately (video/mp4
, video/x-m4v
, video/quicktime
). can confirm these?
Comments
Post a Comment