Har*_*ish 6 youtube iphone objective-c uiwebview
如何获取YouTube视频UITableViewCell,以及如何处理播放视频的Done按钮UIWebView?
我已将视频嵌入到视图中,但就像在图像上一样.我想Done在这张图片中按钮:

我想在返回视图时打开另一个屏幕,而不是之前的视图.
-(void)viewDidLoad {
[super viewDidLoad];
videoURL = [[NSString alloc]init];
videoURL =@"http://www.youtube.com/watch?v=aE2b75FFZPI";
[self embedYouTube:videoURL frame:CGRectMake(10, 85, 300, 180)];
}
- (void)embedYouTube:(NSString*)url frame:(CGRect)frame {
NSString* embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: red;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>";
NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height];
if (videoView == nil) {
videoView = [[UIWebView alloc] initWithFrame:frame];
[self.view addSubview:videoView];
NSLog(@"html%@",html);
}
[videoView loadHTMLString:html baseURL:nil];
}
Run Code Online (Sandbox Code Playgroud)
我需要一些帮助.我做了一个搜索,但我没有得到任何东西.
由于这个问题暂时没有得到答复,我想我可以提出一个建议。我相信最终结果与您正在寻找的结果相同,但到达那里的路径略有不同。
因此,根据我的理解,您希望 UITableView 控制器显示单击 YouTube 视频时播放的列表。以下是我在我的一个应用程序中处理这种情况的方法。
didSelectRowAtIndexPath 实现
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
/** self.items is just a mutable array of video objects that is the underlying
datasource for the table. The Video object is just a simple value object
I created myself */
Video *video = [self.items objectAtIndex:[indexPath row]];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:video.video]];
[self presentMoviePlayerViewControllerAnimated:mp];
[mp release];
}
Run Code Online (Sandbox Code Playgroud)
这是我的 Video 类的界面的样子
@interface Video : NSManagedObject {
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * link;
@property (nonatomic, retain) NSString * comments;
@property (nonatomic, retain) NSString * thumbnail;
@property (nonatomic, retain) NSString * pubDate;
@property (nonatomic, retain) NSString * video;
@property (nonatomic, retain) NSString * guid;
@property (nonatomic, retain) NSString * desc;
@end
Run Code Online (Sandbox Code Playgroud)
差不多就是这样,这是一种在 UITableViewController 中显示 YouTube 视频的简单好方法。我不会深入讨论 XML 解析,有大量关于如何执行此操作的文档。我刚刚快速谷歌了一下,这个博客实际上深入了解了我正在谈论的内容:
http://useyourloaf.com/blog/2010/10/16/parsing-an-rss-feed-using-nsxmlparser.html
希望这能让你继续前进。我知道这并不能解决将标记放入 WebView 的问题,但我认为您会发现这种方式更直观一些,而且由于还没有太多回复...希望它能让您启动并运行。
| 归档时间: |
|
| 查看次数: |
1375 次 |
| 最近记录: |