Ios – embedding youtube video in iphone app

iosiphoneyoutube-api

I am new to IOS application development. I've added the code for embedding Youtube video in my app by using UIWebview and the embed code from the youtube. But when I run the application in my simulator, the webview is simply blank. I don't see any video thumbnail or anything else. I heard youtube videos will not run on IPhone simulators but this link ("http://www.youtube.com/embed/36db4r3MsgU")shows that the video is playing perfectly in simulator. kindly look into this link and suggest me a solution.

NSString *code = @"<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/36db4r3MsgU?feature=player_detailpage\" frameborder=\"0\" allowfullscreen></iframe>";
[[self video]loadHTMLString:code baseURL:nil];

Thanks,
Abilash.G

Best Answer

No need to use the embed code. The standard UIWebView aimed at the youtube web address should work fine...

// URL from safari address bar. 
NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=fDXWW5vX-64"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];