开发者

Accessing Youtube videos on iphone (objective-c)

Can anyone please guide how to ac开发者_Go百科cess the videos from youtube and play it in iphone. Since i am new to iphone development a better tutorial is mostly appreciated.,

Thanks in Advance.


Google provides youtube API for the same purpose

Please go through he link to get to know more how the API can be used http://code.google.com/apis/youtube/overview.html

Any examples/tutorials on using Google GData API - Youtube on iphone?


This GData sample Code might help you to get data from GData API for fetching info regarding Youtube videos. I use to play videos in UIWebView with help of the following Code

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

Call this function

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

where self.youTubeLink will contain a stringURL to load the YouTube video.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜