我会保持简单,代码如下:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
VideoEntry *entry = [videoEntries objectAtIndex:indexPath.row];
[HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:entry.url] completeBlock:^(NSDictionary *videoDictionary, NSError *error) {
NSArray *urls = [videoDictionary allValues];
NSURL *url = [NSURL URLWithString:[urls objectAtIndex:0]];
[mp.moviePlayer setAllowsAirPlay:YES];
[mp.moviePlayer setContentURL:url];
[mp.moviePlayer prepareToPlay];
[mp.moviePlayer play];
[self presentMoviePlayerViewControllerAnimated:mp];
}];
}
mp 是一个 MPMoviePlayerViewController。显示了视图控制器,但电影没有开始,它只是说“正在加载...”,在你问之前我 100% 确定链接有效。
谢谢!