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
Pretty simple: Just put it inside a static method. Show activity on this post. Use this Youtube Embed API from google.
Adding the library In this example, we are going to add the YouTube Player iOS Helper library into our project using Cocaopods. Next, in the swift file of your ViewController, add with drag and drop the YTPlayerView and add import youtube_ios_player_helper at the top of your file.
While iOS users have had the tap-to-upload option for YouTube in the Photos app lately, recent versions have it missing. But we’ve got it sorted for you! Read on this blog to know the easiest and fastest ways to upload YouTube videos from your iPhone or iPad.
Open a Safari app on your iPhone and go to Youtube.com Sign in with your details. Then tap on your Account icon on the top right corner. Tap on the Upload icon.
Open the YouTube app on your iPhone. Tap on the Record icon on the top right If asked, give YouTube permission to access your camera and photos. There will appear three options.
Open the YouTube app and sign in, if not already. Tap the ‘+ icon’ at the bottom. Choose ‘Upload a video ‘ from the options. Allow access in the pop-up that appears. Now, you can choose the video you want to upload from your files or tap the record option to record and upload the video directly.
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];
@danh answer does work, but it embeds youtube's mobile webpage with the youtube player, which takes a lot of space and it looks terrible. The best option is to follow the instructions in the Youtube Api Blog:
UPDATE: Since youtube now uses v3 of its api, here is a new link with the oficial instructions: https://developers.google.com/youtube/v3/guides/ios_youtube_helper
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With