gdata youtube查询问题 [英] gdata youtube query problem

查看:62
本文介绍了gdata youtube查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前曾问过这个问题,但是没有答案.所以再问一次.

i have asked this question before but no answer was there. so asking again.

我只是不知道要使用哪个gdata框架类,以便我可以搜索youtube视频.我通过调试代码使用了一些类,但是我认为框架太深了,以至于要花很多时间才能解决这个问题.所以请帮帮我.我在我的应用程序中有一个搜索框,我希望在该搜索框中输入任何关键字并点击搜索按钮后,我应该得到正确的响应.我尝试了一些代码,但始终会返回相同的结果.

I just cant figure out which gdata framework class to use so that i can search youtube videos . i used some classes by debugging code but i think the framework is so deep that it can take a lot of time to figure out this problem . so please help me . i have a search box in my app and i want that after entering any keyword(s) in that search box and tapping the search button i should get the proper response . i tried some code but always it returns the same result.

这是我的代码...

-(void)searchYoutube
{

NSString *searchString = [NSString stringWithFormat:@"%@", searchField.text];

NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForFeedID:nil];


GDataQueryYouTube* query = [GDataQueryYouTube  youTubeQueryWithFeedURL:feedURL];
[query setStartIndex:1];
[query setMaxResults:50];

//[query setFullTextQueryString:searchString];
[query setVideoQuery:searchString];
GDataServiceGoogleYouTube *service = [self youTubeService];

GDataServiceTicket *ticket;
ticket = [service fetchFeedWithURL:feedURL                    delegate:self
                 didFinishSelector:@selector(ticket:finishedWithFeed:error:)];



 }

下面是cellForRowAtIndexPath:方法的代码

below is the code of cellForRowAtIndexPath: method

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


NSString *CellIdentifier = @"Cell";

    CustomCellVideoList *cell = (CustomCellVideoList *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[CustomCellVideoList alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;




    // Configure the cell.
    GDataEntryBase *entry = [[feed entries] objectAtIndex:indexPath.row];
    //NSString *title = [[entry title] stringValue];
    NSArray *thumbnails = [[(GDataEntryYouTubeVideo *)entry mediaGroup] mediaThumbnails];

    GDataYouTubeMediaGroup *mediaGroup = [(GDataEntryYouTubeVideo *)entry mediaGroup];
    GDataMediaDescription *desc = [mediaGroup mediaDescription];
    GDataMediaTitle *mTtile = [mediaGroup mediaTitle];
    NSLog(@"media  group----- \n\n%@",[(GDataEntryYouTubeVideo *)entry mediaGroup]);
    cell.videoTitle.text = [mTtile stringValue ] ;
    cell.videoDesc.text = [desc stringValue];

    // GDataMediaContent has the urls to play the video....

    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[thumbnails objectAtIndex:1] URLString]]];
    //cell.videoImgView.image = [UIImage imageWithData:data];
    cell.data = data;

}

非常感谢您的帮助

谢谢

推荐答案

查询对象将查询参数添加到Feed网址上.

The query object adds the query parameters onto the feed URL.

您可以使用NSLog(@%@",[查询URL])看到完整的查询字符串

You can see the full query string with NSLog(@"%@", [query URL])

使用[service fetchFeedWithQuery:query ...]进行提取 或等效的[service fetchFeedWithURL:[query URL] ...]

Do the fetch with [service fetchFeedWithQuery:query ...] or the equivalent [service fetchFeedWithURL:[query URL] ...]

这篇关于gdata youtube查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆