Any examples/tutorials on using Google GData API - Youtube on iphone?

前端 未结 1 639
野的像风
野的像风 2020-12-08 17:40

I need to list a specific users uploaded videos (YouTube) in a UITableView. I\'ve downloaded the GData source and example projects (not iphone specific) but I can\'t seem to

相关标签:
1条回答
  • 2020-12-08 18:16

    Assuming you have included the GData client libraries to your project, you need to make a call to fetch the user's uploads, and then display them. Here's the simplest way I can think of:

    Create an instance variable in your table view controller class that will hold the feed data returned from the YouTube API.

    RootViewController.h

    #import "GDataYouTube.h"
    #import "GDataServiceGoogleYouTube.h"
    
    @interface RootViewController : UITableViewController {
        GDataFeedYouTubeVideo *feed;
    }
    
    @property (nonatomic, retain) GDataFeedYouTubeVideo *feed;
    

    Inside the implementation file, make a call to the API to fetch all uploaded videos. Inside the callback selector request:finishedWithFeed:error, store the results in whatever format suits, and reload the table view. In the table views cellForRowAtIndexPath method, format the cell as desired:

    RootViewController.m

    // get the youtube service
    GDataServiceGoogleYouTube *service = [self youTubeService];
    
    // feed id for user uploads
    NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
    // construct the feed url
    NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:@"annoyingorange"
                                                userFeedID:uploadsID];
    
    // make API call
    [service fetchFeedWithURL:feedURL
             delegate:self
             didFinishSelector:@selector(request:finishedWithFeed:error:)];
    

    Checkout the full source code for RootViewController.

    0 讨论(0)
提交回复
热议问题