在我的应用程序中,我想播放 N 个 utube 视频 我的服务器中有 YouTube
url 数组,所以现在我想在我的 UITableView
中查看 utube 视频一旦用户单击单元格,它就必须在详细 View 中播放特定视频。
我已经使用 HCYoutubeParser
播放了 YouTube
视频,但没有使用 UIWebView
也没有重定向到 utube。现在我在这里面临一些问题
我已经使用 NSObject
从服务器获取 URL
和标题,并且我正在使用 setDataSource
方法来查看视频。
我的setDataSource
代码
-(void)setDataSource:(videopolitical *)inVideosObj
{
self.title.text = inVideosObj.title;
NSDictionary *videos = [HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:inVideosObj.video]];
MPMoviePlayerViewController *mp = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[videos objectForKey:@"medium"]]] autorelease];
[self presentViewController:mp animated:YES completion:nil];
}
在上面的代码中,最后一行 [self presentViewController:mp animated:YES completion:nil];
显示警告。
Instance method' - presentViewController:animated:completion:'not found(return type defaults to 'id')
请告诉我如何解决这个问题以及如何在 UITableView
中播放 utube 视频数组
最佳答案
如果对UIWebView
的使用没有限制,那么我建议使用UIWebView
。这很简单这是例子。
NSString *htmlString = [NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@",
@"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head><body style=\"background:#000;margin-top:0px;margin-left:0px\"><div><object width=\"212\" height=\"172\"><param name=\"movie\" value=\"",
youTubeUrl,
@"?f=gdata_videos&rel=0\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"",
youTubeUrl,
@"?f=gdata_videos&rel=0\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\" ",
width,
@"\"height=\" ",
height,
@"\"></embed></object></div></body></html>"];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[_youTubeWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.meuglobal.com"]];
关于ios - 如何在 UItableview IOS7 中播放 youtube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23361292/