Skip to content

Instantly share code, notes, and snippets.

@SongJiaqiang
Created October 13, 2016 11:26
Show Gist options
  • Save SongJiaqiang/f636d287c06d32031a5fcbf0a4860ef9 to your computer and use it in GitHub Desktop.
Save SongJiaqiang/f636d287c06d32031a5fcbf0a4860ef9 to your computer and use it in GitHub Desktop.
// import them, FacebookSDK.framework, FBSDKLoginKit.framework, FBSDKShareKit.framework, Bolts.framework,FBSDKCoreKit.framework
- (void)shareVideoToFacebook {
if(![FBSDKAccessToken currentAccessToken]) {
FBSDKLoginManager *login1 = [[FBSDKLoginManager alloc]init];
[login1 logInWithPublishPermissions:@[@"publish_actions"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = videoAssetURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
[FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];
}];
}
else {
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = videoAssetURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
[FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];
}
}
- (void)writeVideoToAlbum {
NSURL *movieURL = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"moviename" ofType:@"mov"]];
// NSURL *movieURL = [NSURL URLWithString:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"] stringByAppendingFormat:@"/movie.mov"]];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:movieURL completionBlock:^(NSURL *assetURL, NSError *error) {
videoAssetURL =assetURL;
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment