Can I search youtube videos in iPhone app? [duplicate] - iphone

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
How can I do a search for video on youtube in my iPhone app?
I am writing an iPhone app that searches videos with category(tags) from youtube and playing them.
I can make it to play youtube videos in the app with url but I wonder how to search videos from youtube and get urls of videos in my iphone app.
Is there any sample code or tutorial to do that?

sure look there how you can do this for begin in a webView:
- (void)viewDidLoad {
NSString *urlAddress = #"http://youtube.video.link.there";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[youtubeWebView loadRequest:requestObj];
//This is for stop bounce of the webView if you want
[[[youtubeWebView subviews] lastObject] setAlwaysBounceVertical:NO];
}
You can create a small browser web in youtube and load the result in a webView or if you prefer in a webView inside a different xib

Related

Why my page downloaded to folder Documents of iPhone simulator is not loadable?

I made an hybrid app between objective C and javascript. My app works so:
When I press on the first button it will load a UIWebView
In this UIWebView I can save the html to the Documents folder
When I save the website I create a JSON to store informations and I save this JSON to Documents folder
When I press the second button, it will load another UIWebView in which there are a mobile site that read informations from JSON and present this data in a html list
When I press on the name of one site it will load the site from Documents folder
The first 4 points works great, but when I press on the site title I've trouble, indeed, the UIWebView shows me a page in which there are written that the page it's not stored on this server. When I navigate with Finder to the Documents folder of my app and I double click on the html site it shows me it in Safari. Why when I load it with an UIWebView doesn't work? I will post here a screenshot to understand my flow.
CODE: I post here the code to load the html:
viewDidLoad method where I call the method to load my page
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.webView.delegate = self;
//[self loadWebsite:#"http://localhost/root/main/index.html"];
[self loadWebsite:#"http://192.168.2.1/root/main/index.html"];
}
loadWebsite method
-(void)loadWebsite:(NSString*)site
{
NSURL *url = [NSURL URLWithString:site];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.webView setScalesPageToFit:YES];
[self.webView loadRequest:request];
}
This seems like a problem with how you are loading your html file into the webview. You should post the code where you are loading the uiwebview.
To load a webview with a local file use the following code :
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:#"htmlfilename" ofType:#"html" inDirectory:#"Documents"]];
[webview loadRequest:[NSURLRequest requestWithURL:url]];
You can refer to this post : Load resources from relative path using local html in uiwebview

How do I get rid of white border around youtube video embedded in UIWebView?

In my iPad application I have a UIWebView with a youtube video embedded in it. I have matched the UIWebView size and the size of the embedded video as well as made sure that the aspect ratio was correct. I have set the UIWebView background color to clear color with no luck. How can I center the embedded video inside my UIWebView. I also used content mode: center and it doesn't seem to respect it. See the screenshot below:
http://cl.ly/1N3c0d343r3v1i0J1h0d
NSString *video_ID = #"7Ek1QwGp9Tw?rel=0";
NSString *htmlStr = [NSString stringWithFormat:#"<iframe class=\"youtube-player\" type=\"text/html\" width=\"453\" height=\"255\" src=\"http://www.youtube.com/embed/%#\" frameborder=\"0\"></iframe>",video_ID];
[webView loadHTMLString:htmlStr baseURL:nil];
Any help would be appreciated.
just a wild guess: you need to reset the margins and paddings of your html documents body and the youtube iframe.
edit add something like <html><head><title>.</title><style>body,html,iframe{margin:0;padding:0;}</style></head><body>[YOUR YOUTUBE CODE]</body></html>
Don't use an iframe, just load the video directly in the webview (a webview is basically like a "native" iframe anyway):
NSString *URLString = [NSString stringWithFormat:#"http://www.youtube.com/embed/%#",video_ID];
NSURL *URL = [NSURL URLWithString:URLString];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
[webView loadRequest:request];

how to show rss feed url in UIWebView in iphone sdk?

I am trying to display url in UIWebView but I can not display, webview just call the fail with error method. My url is this "http://www.tekniknoktamarket.com/index.php?route=feed/google_base",
So please help me how to display this url in UIWebView *?*
In order to have a UIWebView download and display the content from a URL, you need to go through a couple of layers of abstraction, the first being an instance of NSURL, which contains your URL string. Then, you hand the NSURL to an instance of NSURLRequest. Finally, you hand the NSURLRequest to the webView. It all looks something like this:
NSURL *url = [NSURL URLWithString:#"www.your-url.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[yourWebView loadRequest:request];
That should do it.
This is the code loading a URL into a webview:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.theurl.com"]]];
If you're using this code and are encountering any problems, please provide the code you were using and the exact error

playing stream video using UIWebView issue

I'm currently developing an ipad application that will play video from wowza streamiong server.
Plainly saying, I load video into UIWebView as follows:
NSURL *videoURL = [NSURL URLWithString:#"http://fishki.tv:1935/vod/mp4:20100731194117.mp4/playlist.m3u8"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:videoURL];
UIWebView * WView = [[UIWebView alloc] init];
WView.frame = CGRectMake(0,0,300,200);
[self.view addSubview:WView];
[WView loadRequest:requestObj];
It plays video ok (you can try yourself), BUT when i try to load another video (or even the same one) by changing videoURL and calling loadRequest method again, it plays only sound without video.
I'm starting to think that it is a bug in ipad simulator because I was unable to fix it anyhow.
I would be glad to hear any suggestions because I also was unable to find similar problem on the web. Thanks in advance.
The web view behaves erratically on Simulator. Can you try the same on a regular device? I believe it might actually be working.

Plug-in handled load UIWebview

I am developing an iPad application that plays videos from Internet Video Archive (IVA).
I can play the IVA URL in iPad-Safari. But, I am able to get it streamed in my app.
I am doing the following things to play the video:
Add an outlet to webview in the nib.
I have written the following code in my play method:
NSString *myURl = //Internet Video Archive URL; the video is in mp4 format
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webview.frame = webFrame;
[webview setDelegate: self];
[webview loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: myURl]]];
It gives the following error:
Error Domain=WebKitErrorDomain Code=204 UserInfo=0x1b2e30 "Plug-in
handled load"
I could play videos from other sites. Could someone help me to solve this problem?
Thanks in advance.
Regards,
Deepa