如何从youtube下载视频并保存(目标c)?

时间:2016-01-29 06:53:37

标签: ios objective-c youtube youtube-data-api nsurlsessiondownloadtask

如何从you-tube下载视频并保存在我的app文件夹中。我有videoID,但没有工作代码。我找到了这个链接,但是这个链接的代码对我不起作用。

Save Youtube video to iPhone in the app

如果有人有任何工作代码,请与我分享,谢谢。

1 个答案:

答案 0 :(得分:1)

设置您的YouTube网址

- (void)downloadMultiAFN:(NSString *)userIDFrom messageId:(NSString *)msgId message:(NSString *)message url:(NSString *)url contact:(NSString *) contact nickName:(NSString *)nickName  {
    imageUrlPathForSharingMessgeId=msgId;

    NSURL *URL = [NSURL URLWithString:url];
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];
    AFHTTPRequestOperation *downloadRequest = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    [downloadRequest setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSData *data = [[NSData alloc] initWithData:responseObject];

// you can save video or image with avi or png  
      //  [[DBManagernew getSharedInstance] saveDataUploadImage:msgId isRead:NO isSend:YES isReceipt:NO image:data];
      //  imageIsSelected=NO;
  // [self fetchAllMessage];



    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"file downloading error : %@", [error localizedDescription]);
    }];

    [downloadRequest start];


}