how to get YouTube Video URL - iphone

I am looking for Youtube Downloader app .and to download Video Firstly I need to get the URL of the Running video.How do I get the url of the video which i play.
but when I play any video into the simulator it automatically gives me some information of the url..which is
2013-02-21 12:25:26.518 MyTube[682:14003] [MPAVController] Autoplay: Enabling autoplay
2013-02-21 12:25:26.518 MyTube[682:14003] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2013-02-21 12:25:26.518 MyTube[682:14003] setting movie path: http://r19---sn-a5m7lner.c.youtube.com/videoplayback?mt=1361429411&ipbits=8&fexp=919113%2C927902%2C916716%2C916612%2C901447%2C902545%2C920704%2C912806%2C902000%2C922403%2C922405%2C929901%2C913605%2C925006%2C906938%2C931202%2C908529%2C920201%2C930101%2C926403%2C901451&newshard=yes&key=yt1&signature=2AB1FC44B4EDA0C5DDF4E715FDCA19FFB16E0FF7.732382C58B3C8CBC4840D462940DFE2FEC9FBE53&source=youtube&sver=3&mv=m&expire=1361452937&ms=au&itag=36&el=watch&dnc=1&cp=U0hVRlRQUF9IUUNONV9MSlRKOjVNc1BwWTUxSVR2&upn=r3oQUqMCths&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&ip=117.215.128.101&app=youtube_mobile&ratebypass=yes&yms=0PtNsY21DUs&id=2a147a30c3da7601
that means setting movie path url which I needed ..but it comes automatically in the output ..do can i fetch this url ...so that I can download
I am just Playing youtube video into the Webview
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://m.youtube.com"]]];

You can use the YouTube API to fetch the URL. Take a look here and here

Youtube is a little bit tricky in iOS because it's doesn't provide the real video link that obvisioulsy.
There is a good plugin clalled LBYoutubeView which handles to extract the real url for you. You can have a look at the link extractor if you just want to download the video...
Another opportunity is to use the gdata objective c client and and import the extracted link in an UIWebView. But keep in mind that the gdata client doesn't provide you with the real link like the framework above.
And be aware, that UIWebivews in simulators < 6.0 probably do not support playing a youtube video in a UIWebview.
At least here is an example of how to embed a youtube video directly in an UIWebView:
[self.webView loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:
[NSString stringWithFormat:#"%#%#", #"http://www.youtube.com/embed/", #"THEYOUTUBEID"]]]];

You can use HCYoutubeParser:
https://github.com/hellozimi/HCYoutubeParser
NSString *videoUrl = [NSString stringWithFormat:#"https://www.youtube.com/watch?v=%#", videoId];
NSDictionary *videos = [HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:videoUrl]];
videoUrl = videos[#"small"];

Related

How to make vimeo video autoplay on iPhone/iPad?

I'm trying to embed a vimeo video into my app using UIWebView.
Currently my code looks like this and it plays the video fine if you press play, but I would like it to play when the UIWebView loads and I'm not sure how to make that happen.
NSURL *videoURL = [NSURL URLWithString:#"http://player.vimeo.com/video/123456?autoplay=1"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:videoURL];
UIWebView * SignUpVideo = [[UIWebView alloc] init];
MyVideo.frame = CGRectMake(0,125,781,481);
[self.view addSubview:SignUpVideo];
[MyVideo loadRequest:requestObj];
This is placed under -(void)viewDidLoad
The autoplay URL parameter doesn't work in Mobile Safari either. I'm thinking you may be out of luck unless you can get a URL for a direct stream. But in that case you could use the AVPlayer instead of a web view and have all of the flexibility you need.
Here is an interesting discussion about the vimeo direct link URLs: How can I find download links for vimeo videos? . However, according to that, vimeo doesn't allow that technique so you might want to take a look a the developer APIs here: https://developer.vimeo.com
Best regards.

How can I get the Thumbnail from Youtube URL?

NSURL *youTubeURL = [NSURL URLWithString:#"http://www.youtube.com/watch?v=HPwyVw_6vsQ&feature=youtu.be"]; // URL is a string which needs to be placed in #"" and close method call with ].
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:youTubeURL];
imageSel = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
I am using this code for getting thumbnail from the video and this return null value in the
imagesel.can anybody help me to solve this problem I am using YouTube URL .when I am using this code for the video that is in the main bundle then it is working fine.
Do this:
Firstly extract videoID from Video URL Link.
Now refer this link for getting thumbnail of video.
each youtube link has 4 thumbnail
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
this code is very good for
for example
i have this link:
http://www.youtube.com/watch?v=HPwyVw_6vsQ&feature=youtu.be
and the youtube video id is:
HPwyVw_6vsQ
and generated thumbnail from this link is:
http://img.youtube.com/vi/HPwyVw_6vsQ/1.jpg
this is very easy to use
if someone wants HQ image use this link
https://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
If you have a YouTube watch page URL, and you want to get the thumbnail URL, the "correct" way to do that is to use oEmbed:
http://apiblog.youtube.com/2009/10/oembed-support.html
That way you don't have to attempt to parse the video id out of the URL.
But... what you really should be doing is using a iframe embed to display videos in your web page (or UIWebView). The YouTube API Terms of Service covers the supported ways of accessing YouTube content:
https://developers.google.com/youtube/terms

Use Vimeo videos inside iPhone/iPad app

our client's video archive is hosted on vimeo, so I want to know if it is possible to use vimeo videos inside of iOS app so that user could press button and get fullscreen video playing in default video player. Is there any kind of API available for that?
upd: I know that in 2010 there was same question on SO, but maybe things changed during last year.
Get the video id, and load it into a webview using the vimeo player url. It will open the quicktime player in full screen mode on tap of the play button.
urlAddress = [NSString stringWithFormat:#"http://player.vimeo.com/video/%#",videoID];
NSURL *url = [NSURL URLWithString:urlAddress];
self.requestObj = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestObj];
You can use YTVimeoExtractor to extract the mp4 url that is usable in MPMoviePlayerViewController.

Is there anyway to autoplay online content audio file on ipad

I want to play audio file on ipad which is located on some server. but thing is I want to autoplay audio file using HTML5. Please suggest me the way.
Thanks
The autoplay attribute is purposely disabled on iPhone and iPad:
In Safari on iOS (for all devices,
including iPad), where the user may be
on a cellular network and be charged
per data unit, preload and autoplay
are disabled. No data is loaded until
the user initiates it. This means the
JavaScript play() and load() methods
are also inactive until the user
initiates playback, unless the play()
or load() method is triggered by user
action. In other words, a
user-initiated Play button works, but
an onLoad="play()" event does not.
Having said that there are some hacks for iOS 3 and iOS 4 to work around this with JavaScript. On iOS 3 you can create a link element and then simulate a click event to trigger the media element to play; on iOS4 you can simply call the load() and play() methods directly on the element.
Try this
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString:#"www.example.com/play.mp3"] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 10];
[myWebView loadRequest: request];
[request release];
Hope this helps!!!

UIWebView not playing YouTube videos

Running into an issue where I am trying to play a YouTube video through a custom UIViewController which contains a UIWebView. All web pages load fine in the UIWebView but if I go to play a YouTube video nothing is displayed. I can hear the video and the status bar is displayed at the top the screen but I can't see any video.
I've researched this a bit to find that...
-YouTube videos may not play in the simulator so I tried it on my device (iPhone 4 with iOS 4.1) to no avail
-There may be issues when trying to play a YouTube video when tethered and deploying through XCode so I tried deploying to my iPhone and then untethering. Video still does not play and I get the same results as noted above.
I'm suspicious that a MPMoviePlayer may be getting childed to the UIWebView but the view portion of that movie player is not being set for some reason which is why I'm not seeing it. Not completely sure about that.
I am seeing alot of threads on this issue but nothing has led me to a solution yet. If there is any input you can offer it would be greatly appreciated.
I Assume you're using Embed Video, i have created HTML file and inserted the Embed video tags and in my web view i use the following:
[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"AboutiPad" ofType:#"html"] isDirectory:NO]]];
it will work for both Simulator and devices this snippet is tested and is being used now, Good luck
Are you trying to play a youtube video with an https URL?
I've noticed that if I try to embed videos with https, they don't always work on some devices.
I basically used the info from this post: Embedding YouTube videos on
But made sure I ran my URL parameter through the following code before putting it into the HTML template:
NSRange range = [urlString rangeOfString:#"https"];
if (range.length == 5 && range.location == 0) {
urlString = [urlString stringByReplacingCharactersInRange:range withString:#"http"];
}