无法使用UIWebView为iOS应用程序播放视频

时间:2014-08-20 16:35:18

标签: ios objective-c video

我尝试使用UIWebView为iOS应用程序实现视频播放。这是我的代码,但我看不到任何视频播放。知道这里有什么问题吗?

(void) viewDidLoad {
    [super viewDidLoad];

    float width  = 200.0f;
    float height = 200.0f;

    NSString *youTubeToken = @"K95Q0VFyhA8";

    UIWebView *webView = [UIWebView new];
    webView.frame = CGRectMake(60, 60, width, height);

    NSMutableString *html = [NSMutableString string];
    [html appendString:@"<html>"];
    [html appendString:@"<head>"];
    [html appendString:@"<style type=\"text/css\">"];
    [html appendString:@"body {"];
    [html appendString:@"background-color: transparent;"];
    [html appendString:@"color: white;"];
    [html appendString:@"margin: 0;"];
    [html appendString:@"}"];
    [html appendString:@"</style>"];
    [html appendString:@"</head>"];
    [html appendString:@"<body>"];
    [html appendFormat:@"<iframe id=\"ytplayer\" type=\"text/html\" width=\"%0.0f\" weight=\"%0.0f\" src=\"http://www.youtube.com/embed/%@\" frameborder=\"0\"/>", width, height, youTubeToken ];
    [html appendString:@"</body>"];
    [html appendString:@"</html>"];

    [webView loadHTMLString:html baseURL:nil];

    [self.view addSubview:webView];
}

0 个答案:

没有答案