How to share video from UIActivityViewController to Vimeo or Facebook using Swift
I am trying to share a video to Vimeo and Facebook. I can do it from the Library, but when I try to build it in code, it fails so much that I tried it.
func showSheet() {
let bundle = NSBundle.mainBundle()
let videoURL:NSURL = NSURL.fileURLWithPath(self.outputUrl!)!
//let asset:AVAsset = AVAsset.assetWithURL(videoURL) as AVAsset
let asset:ALAsset = ALAsset.setVideoAtPath(videoURL)
//NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.mov"];
//NSURL *videoURL = [NSURL fileURLWithPath:myFilePath];
let objectsToShare = [textToShare, asset]
//let objectsToShare = [textToShare, videoURL]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityTypeAddToReadingList]
self.presentViewController(activityVC, animated: true, completion: nil)
}
As you can see from the comments, I've tried passing NSURL, AVAsset and, and ALAsset, the only thing that works is NSURL. I can send it via iMessage, but it doesn't work for Facebook. Also, Vimeo and YouTube never appear in the list, even though they do appear when I launch a sheet from the photo library. What am I doing wrong? By following the data grid at the bottom of this page , I should be able to transfer the asset.
+3
source to share
No one has answered this question yet
Check out similar questions: