2011-03-14 117 views

回答

0

This GData sample Code 可以帮助你得到来自GData API的数据,用于获取有关Youtube视频的信息。我用在UIWebView中播放视频下面的代码的帮助

- (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\">\ 
<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];} 

调用此函数

[self embedYouTube:self.youTubeLink frame:CGRectMake(0, 0, 320, 370)]; 

其中self.youTubeLink将包含stringURL加载YouTube影片。