gdata youtube query problem

 ̄綄美尐妖づ 提交于 2020-01-02 08:28:35

问题


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

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.

here is my code...

-(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:)];



 }

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;

}

any help is greatly appreciated

Thanks


回答1:


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

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

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



来源:https://stackoverflow.com/questions/4969392/gdata-youtube-query-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!