How to share a video from UIActivityViewController to Vimeo or Facebook using Swift

773 views Asked by At

I'm trying to share a video to Vimeo and or Facebook. I'm able to do it from the Library, but when I try to create it in code, it fails this far I have tried this

  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 commented lines, I have tried passing an NSURL, An AVAsset and, and ALAsset, the only one that works is the NSURL. I am able to send it via iMessage, but it does not work for Facebook. Furthermore, Vimeo and YouTube never show up in the list, even though they show up when I trigger the sheet from the photo Library. What am I doing wrong? Following the data grid at the bottom of this page I should be able to pass an asset.

0

There are 0 answers