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
Related
I have an app I am working on in Xcode. Part of the app area loads an html file. The HTML file itself has some links to external websites. They open fine, except they are not scaled to fit on the iPhone.
How would I go about ensuring all web pages opened are scaled to fit? The code from the .m file is below
NSString *fileString = [[NSBundle mainBundle] pathForResource: #"chapter5" ofType: #"html"];
NSURL *newURL = [[NSURL alloc] initFileURLWithPath: fileString];
NSURLRequest *newURLRequest = [[NSURLRequest alloc] initWithURL: newURL];
[webview loadRequest: newURLRequest];
The HTML file "chapter5.html contains links to websites.
I thought I would try entering
webview.scalesPageToFit = YES
in the .m file hoping it would apply to anything opened, but that didn't work.
Any advice would be greatly appreciated.
Thanks
The scalesPageToFit will take effect only when the webView loads the request. Implement the delegate of UIWebView webViewDidFinishLoad: method and try this code.
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
CGSize defaultSize = webView.frame.size;
CGSize fittingSize = [tableViewCell.webView sizeThatFits:defaultSize];
[webView sizeThatFits:fittingSize];
NSLog(#"Size : %#",NSStringFromCGSize(fittingSize));
}
Please set webview mode as Aspect-Fit
Thanks guys, I set webview mode as Aspect-Fit and set the Scaling to scale pages to fit and this worked, not sure how I missed that.
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];
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
I have a media streaming code like below for playing streaming video. I want to test it with some working streaming url feed on iOS 4 devices. Could someone provide me the exact sample streaming video feed if anything is available for iPhone supported? So that, i can test this code and make sure it works well, though it could be correct. I want a real streaming video url link.
NSString *strUrl = #"http://????????????"
NSURL *url = [NSURL URLWithString:strUrl];
MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
mPlayer.view.frame = self.view.frame;
[self.view addSubview:mPlayer.view];
[mPlayer setFullscreen:YES animated:YES];
[mPlayer play];
Thanks.
I don't have a URL for you, but your code looks correct, except that you should turn auto-play off before setting full screen with animation. In my experience, the app could crash on setFullscreen:animated: if you use the player more than once. You might also want to observe the MPMoviePlayerPlaybackDidFinishNotification notification in case of playback error so that you can inform the user that there was a playback error.
NSURL *url = [NSURL URLWithString:strUrl];
MPMoviePlayerController *mPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url]; mPlayer.view.frame = self.view.frame;
mPlayer.shouldAutoplay = NO;
[self.view addSubview:mPlayer.view];
[mPlayer setFullscreen:YES animated:YES];
[mPlayer play];
You can use below urls for testing purpose,
http://a1408.g.akamai.net/5/1408/1388/2005110405/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_mpeg4.mp4
I have not tested it, but it should work well...
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.