iphone Gdata youtube api限制收到的视频数量

时间:2011-04-01 12:16:28

标签: iphone limit youtube-api gdata-api

Hy我正在尝试从用户那里获取所有视频并将它们放在列表视图中。我下了一个关于如何在iphone上执行此操作的教程,并提出了这个问题。但由于此特定用户拥有超过500个视频,因此这种方法需要花费大量时间来加载视频节目。我看到这是一种让视频成为链接的方法 http://gdata.youtube.com/feeds/api/users/PsyStarcraft/uploads?max-results=50&start-index=51 关于如何加载它们而不是让手机用户等待的任何想法?

'GDataServiceGoogleYouTube *service = [self youTubeService];

NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:@"HuskyStarcraft"
                                                     userFeedID:uploadsID];

[service fetchFeedWithURL:feedURL
                 delegate:self
        didFinishSelector:@selector(request:finishedWithFeed:error:)];

[super viewDidLoad];'

1 个答案:

答案 0 :(得分:1)

我这样做但查询setMaxResults不起作用。设置开始索引工作正常。任何想法?

GDataServiceGoogleYouTube *service = [self youTubeService];

        NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
        NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:ytid
                                                             userFeedID:uploadsID
                          ];

            NSLog(@"%@", [feedURL path]);
        GDataQueryYouTube* query = [GDataQueryYouTube  youTubeQueryWithFeedURL:feedURL];
        [query setStartIndex:1];
        [query setMaxResults:2];



            [service fetchFeedWithQuery:query
                               delegate:self
                      didFinishSelector:@selector(request:finishedWithFeed:error:)];

后来,解决了它:

- (GDataServiceGoogleYouTube *)youTubeService {
static GDataServiceGoogleYouTube* _service = nil;

if (!_service) {
    _service = [[GDataServiceGoogleYouTube alloc] init];

    [_service setUserAgent:@"AppWhirl-UserApp-1.0"];
    [_service setShouldCacheDatedData:YES];
    [_service setServiceShouldFollowNextLinks:NO];
}

// fetch unauthenticated
[_service setUserCredentialsWithUsername:nil
                                password:nil];

return _service;
}

修改后的行是

  

[_ service setServiceShouldFollowNextLinks:NO];

顺便说一下,这是从以下代码修改的:http://pastebin.com/vmV2c0HT