iPhone 在网页 View 中播放 YouTube 视频

标签 iphone html ios5 uiwebview

我无法播放这种格式的视频。

http://www.youtube.com/embed/lNOMZoF9VlM?rel=0

我的 html 字符串。

NSString *html = [NSString stringWithFormat:@"<html><head>\
                              <body style=\"margin:0\">\
                              <embed id=\"yt\" src=%@ type=\"application/x-shockwave-flash\" \
                              width=\"120\" height=\"120\"></embed>\
                              </body></html>",str];

请回复。

最佳答案

试试这个,它对我有用......

    CGRect frame = CGRectMake(40, 55, width, height);


    NSString *embedHTML =[NSString stringWithFormat:@"\
                          <html><head>\
                          <style type=\"text/css\">\
                          body {\
                          background-color: transparent;\
                          color: blue;\
                          }\
                          </style>\
                          </head><body style=\"margin:0\">\
                          <iframe height=\"220\" width=\"400\" src=\"http://www.youtube.com/embed/lNOMZoF9VlM\"></iframe>\
                           </body></html>"];

    webview = [[UIWebView alloc] initWithFrame:frame];

    webview.backgroundColor = [UIColor clearColor];

    webview.scrollView.scrollEnabled =NO;

    [webview loadHTMLString:embedHTML baseURL:nil];

    [self.view addSubview:webview];

关于iPhone 在网页 View 中播放 YouTube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12209994/

相关文章:

ios - UIWebView 和 WKWebView 导航

ios - 如何按降序对字符串中包含日期的数组进行排序?

iphone - 在 iPhone 上显示启动/加载屏幕的时间更长

iphone - 支持 iOS 当前使用的多种艺术尺寸的最佳方式是什么?

html - 模态中的日期选择器

iphone - 在 iPhone 上存储数据的最佳方式是什么?

ios - 我的屏幕上正在模拟哪款 iPhone?

html - 第 n 个类型;如何在一个 ( ) 中定位多个 div

javascript - 调用 Jquery Val() 后,Append() 不起作用

iphone - 将 NSString "2012-06-29"形成为 NSDate 的 "NSDateFormatterMediumStyle"?