ios - iOS上载带有视频信息GTLServiceYoutube的视频

标签 ios objective-c video youtube youtube-data-api

我想将视频上传到YouTube channel 。我尝试使用以下代码。以下代码可以上传视频,但问题是我无法附加其信息(视频标题,描述和标签)。上传后仅显示视频标题作为“未知”且没有标签或描述。我见过CodingTofuDev7Dev Blog- iOS Sample Code和许多其他问答,但我不明白自己在哪里犯错。

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

告诉我是否需要其他详细信息
谢谢。
对不起,我的英语不好。

最佳答案

我误会了
在上面的代码中,我必须添加

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........

这可能会对遇到相同问题的人有所帮助。

关于ios - iOS上载带有视频信息GTLServiceYoutube的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36077449/

相关文章:

iphone - iOS 上的 Chartboost : Not able to stop session

ios - 如何在ios中实现instagram similar like效果?

ios - 如何在选项卡式应用程序中的 ViewController 之间共享数据

ios - 为什么 EDAMNote.content 为空?

android - 将视频文件存储在内部或 SD 卡存储器上并受到保护?

python - 什么是处理视频文件帧的好 Python 库?

ios - 具有透明背景的 Swift 导航 Controller View

iphone - iOS 应用程序缺少屏幕截图

ios - XMPPFramework - 创建一个 XMPP Room

opencv - 如何使用 OpenCV_Contrib 检测视频中的地标?