无法在facebook

时间:2015-06-10 09:51:42

标签: ios objective-c facebook video

我想在Facebook上分享视频。
为此,我根据他们的文档下载并设置了FacebookSDK。为此,如果我使用他们的教程代码,可以正常工作。< / p>

-(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];
}

日志记录如下

  

资产   ?URL:资产库://asset/asset.JPG ID = 7D4D3554-6782-446F-A566-BD570754B6ED&安培; EXT = JPG

但是如果按照我的要求更改代码,那么视频就不会出现在共享对话框中。代码如下所示。

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];

日志记录如下

  

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

根据视频分享的facebook文档中的提及,我的视频大小不超过12MB。
我也尝试过如下 video.videoURL = [NSURL fileURLWithPath:myPathDocs];
因为记录如下。

  

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

请帮我解决这个问题。 提前谢谢......

1 个答案:

答案 0 :(得分:1)

试试这个

FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
    content.video = [FBSDKShareVideo videoWithVideoURL:[NSURL fileURLWithPath:myPathDocs]];