如何在iPhone应用程序中嵌入youtube播放器

时间:2011-09-02 12:22:06

标签: iphone objective-c ios ios4

我已经完成了上一个问题并编写了简单的代码..

- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
    NSString *embedHTML = @"\
    <html><head>\
    <style type=\"text/css\">\
    body {\
    background-color: transparent;\
    color: white;\
    }\
    </style>\
    </head><body style=\"margin:0\">\
    <video src=\"point/to/mov\"></video>\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </body></html>";
    NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
    UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
    [videoView loadHTMLString:html baseURL:nil];
    //[videoView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=WL2l_Q1AR_Q"]]];
    [self.view addSubview:videoView];
    [videoView release];
}

如果使用“html”是不显示... 但我们直接加载网址,因为我评论它工作正常......

任何人都可以帮助我摆脱这个问题..

0 个答案:

没有答案