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