Sharing Video to Facebook - Swift IOS -
i'm writing app try , post video facebook. ideally i'd pull video parse, , convert nsurl. right trying use imagepicker pick photo used share.
right have imagepicker showing up, i'm getting 2 errors. 1)only photos showing in roll , 2) i'm getting 'found nil while unwrapping optional value' in didfinishpickingmediawithinfo function. issue 1, have changed uiimagepickercontrollersourcetype .photolibrary still omitted videos.
override func viewwillappear(animated: bool) { let profilebutton = uibarbuttonitem(image: img, style: .done, target: self, action: "videobtnclicked") self.navigationitem.setrightbarbuttonitem(profilebutton, animated: true) func videobtnclicked(){ if uiimagepickercontroller.issourcetypeavailable(uiimagepickercontrollersourcetype.savedphotosalbum){ print("video capture") imagepicker.delegate = self imagepicker.sourcetype = uiimagepickercontrollersourcetype.savedphotosalbum imagepicker.allowsediting = false self.presentviewcontroller(imagepicker, animated: true, completion: nil) } } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { let video : fbsdksharevideo = fbsdksharevideo() //error occurs line below here video.videourl = info[uiimagepickercontrollermediaurl] as! nsurl let content : fbsdksharevideocontent = fbsdksharevideocontent() content.video = video }
- for photo question
func videobtnclicked(){ if uiimagepickercontroller.issourcetypeavailable(uiimagepickercontrollersourcetype.savedphotosalbum){ print("video capture") imagepicker.delegate = self imagepicker.sourcetype = uiimagepickercontrollersourcetype.savedphotosalbum **imagepicker.mediatypes = ["public.movie"]** imagepicker.allowsediting = false self.presentviewcontroller(imagepicker, animated: true, completion: nil) } }
- for second question,you should check url first
func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { let video : fbsdksharevideo = fbsdksharevideo() //error occurs line below here if let url = video.videourl{ video.videourl = info[uiimagepickercontrollermediaurl] as? nsurl let content : fbsdksharevideocontent = fbsdksharevideocontent() content.video = video } }
Comments
Post a Comment