Hi,There may be requirement to play youtube video in iphone or ipad using xcode or objective c language
This functionality is very simple
Checkout the following code (This will only work in device not in simulator)
- (void)embedYouTube:(NSString*)url frame:(CGRect)frame
This functionality is very simple
Checkout the following code (This will only work in device not in simulator)
- (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:CGRectMake(0, 0, 320, 480)];
[webView loadHTMLString:html baseURL:nil];
[self.view addSubview:webView];
}
- (void)viewDidLoad
{
[self embedYouTube:@"http://www.youtube.com/watch?v=lzsBwnv_dAg&feature=player_embedded" frame:CGRectMake(0, 0, 320, 480)];
[super viewDidLoad];
}