2011-03-14 103 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影片。