问题描述:

I want to share video in Facebook.
For that I have download and set up FacebookSDK as per their documentation.
For that If I go with their tutorial code that works fine as per below.

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

NSURL *videoURL = [info objectForKey:UIImagePickerControllerReferenceURL];

FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];

video.videoURL = videoURL;

NSLog("%@",videoURL);

FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];

content.video = video;

[FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];

}

logging comes as per below

asset

URL:assets-library://asset/asset.JPG?id=7D4D3554-6782-446F-A566-BD570754B6ED&ext=JPG

But if I change code as per my requirement then video is not going to appear in share dialog. The code is as per below.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *myPathDocs = [[documentsDirectory stringByAppendingPathComponent:@"Saved Video"] stringByAppendingPathComponent:[player.contentURL lastPathComponent]];;

FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];

video.videoURL = [NSURL fileURLWithPath:myPathDocs];//[NSURL URLWithString:myPathDocs];

FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];

content.video = video;

NSLog("%@",myPathDocs);

[FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];

logging comes as per below

file:///private/var/mobile/Containers/Data/Application/4DF2C574-4A9D-41B8-8666-27472A995F47/Documents/Saved%20Video/hello.mov

My video size not greater then 12MB as per mention in facebook documentation for video sharing.


I have also tried like following

video.videoURL = [NSURL fileURLWithPath:myPathDocs];


For that logging is as below.

file:/private/var/mobile/Containers/Data/Application/4DF2C574-4A9D-41B8-8666-27472A995F47/Documents/Saved%2520Video/hello.mov

Please help me to solve this issue.

Thanks in advance...

网友答案:

Try this

FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
    content.video = [FBSDKShareVideo videoWithVideoURL:[NSURL fileURLWithPath:myPathDocs]];
相关阅读:
Top