我想上传视频到youtube channel.i尝试使用以下Code.the波纹管代码工作上传视频,但问题是,我无法附加其信息(视频标题,描述和标签)。上传后它只显示视频标题为“未知”,没有标签或描述。我见过CodingTofu,Dev7Dev Blog- iOS Sample Code和许多其他Q& A但我无法理解我在哪里弄错了。
NSString* title = video.title;
NSString* description = video.videoDescription;
NSData* data = video.data;
NSMutableArray* tags = video.tags.mutableCopy;
GTLYouTubeVideo *yVideo = [GTLYouTubeVideo object];
GTLYouTubeVideoSnippet *snippet = [GTLYouTubeVideoSnippet alloc];
snippet.title = title;
snippet.descriptionProperty = description;
[tags addObject:DEFAULT_KEYWORD];
NSString* tag = [UploadController generateKeywordFromPlaylistId:UPLOAD_PLAYLIST];
[tags addObject:tag];
snippet.tags = tags;
GTLYouTubeVideoStatus *status = [GTLYouTubeVideoStatus alloc];
status.privacyStatus = @"public";
GTLUploadParameters *uploadParameters = [GTLUploadParameters uploadParametersWithData:data MIMEType:@"video/*"];
GTLQueryYouTube *query = [GTLQueryYouTube queryForVideosInsertWithObject:yVideo part:@"snippet,status" uploadParameters:uploadParameters];
service.uploadProgressBlock = ^(GTLServiceTicket* ticket, unsigned long long totalBytesUploaded, unsigned long long totalBytesExpectedToUpload){
CGFloat percentage = totalBytesUploaded/totalBytesExpectedToUpload;
NSLog(@"\nUploaded percentage %%(%0.2f)",percentage);
};
[service executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLYouTubeVideo *insertedVideo, NSError *error) {
//[waitIndicator dismissWithClickedButtonIndex:0 animated:YES];
if (error == nil)
{
NSLog(@"File ID: %@", insertedVideo.identifier);
return;
}
else
{
NSLog(@"An error occurred: %@", error);
return;
}
}];
告诉我你是否需要任何进一步的细节 谢谢。 抱歉我的英语不好。
答案 0 :(得分:0)
GTLYouTubeVideo *yVideo = [GTLYouTubeVideo object];
GTLYouTubeVideoStatus *status = [GTLYouTubeVideoStatus alloc];
GTLYouTubeVideoSnippet *snippet = [GTLYouTubeVideoSnippet alloc];
*******
*******
*******
yVideo.snippet = snippet;//This part i forgot to add in my code
yVideo.status = status;//This part i forgot to add in my code
[service executeQuery........
这可能会对面临同样问题的人有所帮助。