次のコードを使用して、WebビューでYouTubeリンクを開いています。
[self playVideo:@"www.youtube.com/watch?v=GcpFTAqvLYQ" frame:CGRectMake(0, 44, 1024, 700)];
- (void)playVideo:(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\">\
<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];
[self.view addSubview:videoView];
[videoView release];
NSLog(@"%@",html);
}
このコードの助けを借りて、私は他のユーチューブリンクを開くことができますが、このリンクは開かれていません。
さらに、私はこのリンクをブラウザで使用しており、ブラウザで開かれています。
何が問題なのかわかりません。
何かアイデアがあれば、それを共有してください。
よろしくお願いします...