gdata youtube 查询问题
我以前问过这个问题,但没有答案。于是又问。
我只是不知道要使用哪个 gdata 框架类,以便我可以搜索 youtube 视频。我通过调试代码使用了一些类,但我认为框架太深了,可能需要很多时间才能解决这个问题。所以请帮助我。我的应用程序中有一个搜索框,我希望在该搜索框中输入任何关键字并点击搜索按钮后我应该得到正确的响应。我尝试了一些代码,但总是返回相同的结果。
这是我的代码...
-(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: 方法的代码,
- (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;
}
非常感谢任何
帮助
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查询对象将查询参数添加到提要 URL 上。
您可以使用 NSLog(@"%@", [query URL]) 查看完整的查询字符串 使用
[service fetchFeedWithQuery:query ...] 进行提取
或等效的 [service fetchFeedWithURL:[query URL] ...]
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] ...]