iOS GData多个youtube上传

时间:2011-11-18 22:43:43

标签: ios youtube gdata

我正在制作一个需要将多个视频上传到youtube的应用程序。 GData的问题是我不知道如何将信息传递给它的回调函数,所以我可以区分不同的上传。

(void)uploadTicket:(GDataServiceTicket *)ticket
   finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry
               error:(NSError *)error

在ASIHttpRequest中,有“userInfo”属性允许用户将信息传递给requestFinish回调。在GData youtube上传请求中怎么样?

- (void)uploadToYoutube: (NSString *)login andPassword:(NSString *)password withVideo:(NSData *)videoData forSighting:(SightingDB *)sighting {


    [service setYouTubeDeveloperKey:DEVELOPER_KEY];

    NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser];


    NSString *titleStr =  @"title";

    // gather all the metadata needed for the mediaGroup

    GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
    [titleStr release];

    NSString *categoryStr = @"Entertainment";
    GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
    [category setScheme:kGDataSchemeYouTubeCategory];

    NSString *descStr = @"descripion"

    GDataMediaDescription *desc = [GDataMediaDescription textConstructWithString:descStr];
    [descStr release];

    NSArray *kwords = [[NSArray alloc] initWithObjects:@"xxx",@"weee",nil];
    GDataMediaKeywords *keywords = [GDataMediaKeywords keywordsWithStrings:kwords];



    BOOL isPrivate = NO;

    GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
    [mediaGroup setMediaTitle:title];
    [mediaGroup setMediaDescription:desc];
    [mediaGroup addMediaCategory:category];
    [mediaGroup setMediaKeywords:keywords];
    [mediaGroup setIsPrivate:isPrivate];

    NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:@""
                                               defaultMIMEType:@"video/mp4"];

    // create the upload entry with the mediaGroup and the file data
    GDataEntryYouTubeUpload *entry;

    entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:mediaGroup
                                                          data:videoData
                                                      MIMEType:mimeType
                                                          slug:@"movie.mov"];



    SEL progressSel = @selector(ticket:hasDeliveredByteCount:ofTotalByteCount:);
    [service setServiceUploadProgressSelector:progressSel];

    GDataServiceTicket *ticket;
    ticket = [service fetchEntryByInsertingEntry:entry
                                      forFeedURL:url
                                        delegate:self
                               didFinishSelector:@selector(uploadTicket:finishedWithEntry:error:)];

1 个答案:

答案 0 :(得分:0)

该票证支持setProperty:forKey:以及setUserData:。

或者只使用块回调而不是委托和选择器。