【问题标题】:iOS: Retrieving an entire YouTube playlist (all videos) with YouTube Gdata APIiOS:使用 YouTube Gdata API 检索整个 YouTube 播放列表(所有视频)
【发布时间】:2013-03-18 17:24:36
【问题描述】:

我已经设法在 iPhone 项目中使用 GData。 我还设法获取了所有上传视频和所有播放列表名称。

项目参考:YouTubeList

我需要获取播放列表的所有链接,以便在按下单元格时显示视频(您可以在我添加的项目中看到它是如何工作的)

这里有一些代码,我可以通过它获得播放列表名称:

    // get the youtube service
    GDataServiceGoogleYouTube *service = [self youTubeService];

    // feed id for user playlist
    NSString *uploadsID = kGDataYouTubeUserFeedIDPlaylists;
    // construct the feed url
    NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:kGDataServiceDefaultUser
                                                         userFeedID:uploadsID];
    // make API call
    [service fetchFeedWithURL:feedURL
                     delegate:self
            didFinishSelector:@selector(request:finishedWithFeed:error:)];

    [super viewDidLoad];
}

- (void)request:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedBase *)aFeed
          error:(NSError *)error {

    self.feed = (GDataFeedYouTubeVideo *)aFeed;
    NSLog(@"FEED:%@", [self.feed entries]);
    [self.tableView reloadData];
}

上面的代码列出了我在帐户中拥有的所有播放列表。 我需要获取特定播放列表的视频

【问题讨论】:

  • 这和IDE完全无关,问题是不是关于Xcode的。
  • 好的,我会删除 Xcode

标签: ios youtube-api gdata gdata-api


【解决方案1】:

我用以下方法修复了它:

在viewDidLoad中

NSURL *feedURL = [NSURL URLWithString:@"http://gdata.youtube.com/feeds/api/playlists/PlayList_ID"];
// make API call

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

那么,方法:

- (void)playlistTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedYouTubePlaylist *)feed error:(NSError *)error {
  if(!error)
   {
       // save the feed and reload the table
       self.feed = feed;
       [self.tableView reloadData];
   }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-19
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    • 2016-06-15
    • 2013-07-08
    • 1970-01-01
    • 2012-01-30
    相关资源
    最近更新 更多