0

我在整个互联网上搜索了我的问题:“如何将 youtube 频道加载到 uitableview 中”

我找不到一个好的例子或教程。

请问有人可以帮助我吗?

非常感谢!

4

2 回答 2

2

看起来 youtube 已经提供了一个 API,您可以在其中检索您的信息,请查看此链接:

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

否则你应该在 github 上搜索 youtube 项目。我已经找到了 2 个项目。第一个已经提供了一个预览页面,并在您选择一个后播放视频:

YoutubeBrowserDemo
HCYoutubeParser

当然,您需要了解如何获得您正在寻找的特定渠道,但我认为这应该对您有所帮助。

于 2013-10-08T11:16:06.590 回答
1

添加您的 youtube 频道 ID

类.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];


}

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

在类.h

#import "GData.h"
#import "GDataYouTube.h"
#import "GDataServiceGoogleYouTube.h"
@property (nonatomic, retain) GDataFeedYouTubeVideo *feed;
于 2013-11-18T09:06:22.323 回答