Maor Ben Namer
Maor Ben Namer

Reputation: 27

Load youtube channel to uitableview

i had search in the whole internet for my question: "How to load youtube channel into an uitableview"

I can't find a good example or tutorial.

Please someone can help me?

Thank you very much!

Upvotes: 0

Views: 966

Answers (2)

sankalp
sankalp

Reputation: 757

add your youtube channel ID

class.m

- (void)viewDidLoad
{


     [super viewDidLoad];

        NSString *urlForPlaylist=@"http://gdata.youtube.com/feeds/api/playlists/URchannelID";

          GDataServiceGoogleYouTube *service = [self youTubeService];

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

}

//youtube

- (GDataServiceGoogleYouTube *)youTubeService {


      static GDataServiceGoogleYouTube* _service = nil;

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

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

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

        return _service;

}



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



     self.feed = (GDataFeedYouTubeVideo *)aFeed;
        NSLog(@"feed..////%@",_feed);

}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{


    return[[self.feed entries] count];
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{



    static NSString *CellIdentifier = @"CellR";
        UITableViewCell *cell = nil;

        cell = [self.VideoTableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }

    GDataEntryBase *entry = [[self.feed entries] objectAtIndex:indexPath.row];
        NSString *title = [[entry title] stringValue];

     NSArray *thumbnails = [[(GDataEntryYouTubeVideo *)entry mediaGroup] mediaThumbnails];
        NSLog(@"thumbnails:%@",thumbnails);

     GDataEntryYouTubeVideo *video = (GDataEntryYouTubeVideo *)entry ;

            NSString *videoURL = [[[video links] objectAtIndex: 0] href];


}

/////////////

in class.h

#import "GData.h"
#import "GDataYouTube.h"
#import "GDataServiceGoogleYouTube.h"
@property (nonatomic, retain) GDataFeedYouTubeVideo *feed;

Upvotes: 1

Alex Cio
Alex Cio

Reputation: 6052

It looks like youtube already provides an API where you can retrieve your information have a look at this link:

http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

Otherwise you should search for youtube projects on github. I already found 2 projects. The first one provides already a preview page and plays the video after you selected one:

YoutubeBrowserDemo
HCYoutubeParser

Of course you would neet to look how to get the specific channels you are looking for but I think this should help you for the beginning.

Upvotes: 2

Related Questions