0

I'm trying to implement video playback using UIWebView for an iOS application. This is my code but I can't see any video playing. Any idea what is wrong here?

(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 Answers0