YouTubeの動画を組み込む

メソッド

- (void)embedYouTube:(NSString*)url 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, url, frame.size.width, frame.size.height];
    UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
    [webView loadHTMLString:html baseURL:nil];
    [self addSubView:webView];
}

呼び出し例

[self embedYouTube:@"http://www.youtube.com/watch?v=tUZXsd325U0" frame:CGRectMake(0, 0, 60, 60)];

参考

http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application