Reputation: 1462
How can I do this...
I have a UIwebview in my iPhone application that loads Youtube's Home Page. The user can search for videos and watch them...
What I want is to grab the video id (from Youtube) of each video the user watches...
I noticed in the desktop version it is displayed in the url, but in the mobile version the url doesn't contain the video id...
Does anyone have an idea on how to get the video id of a youtube video in a webview...
My past idea:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
NSLog(@"%@",urlString);
VideoURLTextBox.text = urlString;
return YES;
}
This gets the url of the webview everytime a webpage loads, too bad Youtube doesn't display their video id in the mobile version of their site....
Help!???
Upvotes: 1
Views: 589
Reputation: 1401
Youtube does display the video id in the url on the mobile site. For example:
http://m.youtube.com/watch?gl=US&hl=en&client=mv-google&v=HX6SyoZ5kw8
Here the video id is the string following &v=
.
Upvotes: 1