Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

embedding youtube video in iphone app

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

like image 721
Abilash Avatar asked Jul 29 '13 01:07

Abilash


People also ask

Can I embed YouTube videos on my app?

Pretty simple: Just put it inside a static method. Show activity on this post. Use this Youtube Embed API from google.

How do I embed a YouTube video in iOS Swift?

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.

Can you upload YouTube videos to photos on iPhone or iPad?

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.

How to upload YouTube videos to Safari on iPhone?

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.

How to record YouTube videos on iPhone?

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.

How to upload videos to YouTube from Android?

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.


2 Answers

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];
like image 172
danh Avatar answered Oct 16 '22 10:10

danh


@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

like image 31
Nick Avatar answered Oct 16 '22 08:10

Nick