Iphone MPMoviePlayerController "the server is not correctly configured"? - iphone

On the iphone, when trying to play a broken url using MPMoviePlayerController the user gets an alertbox with the message "the server is not correctly configured".
Is there any way to change this to something more user-friendly? Alternatively, is there any way to get an error status from the player instead of getting this message?
Thanks in advance..

MPMoviePlayer provides two notifications for the case of a broken / invalid movie URL:
From MPMoviePlayer initWithContentURL:
To check for errors in URL loading, register for the MPMoviePlayerContentPreloadDidFinishNotification or
MPMoviePlayerPlaybackDidFinishNotification notifications.
On error, these notifications contain an NSError
object available using the #"error" key in the notification’s userInfo dictionary.
You should be able to hook to one oh these notifications and perform the needed actions
if a broken URL is about to be loaded.

Usually this error message means that the web server that's serving the file does not support HTTP byte ranges.
iPhone OS uses HTTP byte ranges for streaming audio and video content. This makes it possible to "scrub" forwards and backwards in the content without downloading the entire content first.

Once I've got this error when trying to play urlencoded url string. I removed urlencoding method call before ask MPMoviePlayerController to play url and everything ok.

Related

Read the page header from a UIWebView

I'm looking for a solution for reading the http status code with a UIWebView.
I have found this page on the topic How do I get the last HTTP Status Code from a UIWebView? but i cannot use AsiHttpRequest in my case.
Si I was wondering if somebody have found a solution since 2009, and if something similar to NSLog(#"Status code = %#",[webView stringByEvaluatingJavaScriptFromString:#"document.status"]);
could possibly work.
Thanks,
I don't think you can get it from the UIWebView, but I think it would work to have the result of an HTTP request put into an NSString, then parse the status code out of the header part of that string, thing feed that string to a UIWebView.
See the NSURL Class Reference and the URL Loading Programming Guide.
A possible alternative would be to implement an HTTP proxy directly inside your App, then feed a localhost URL to UIWebView. Your proxy would just make an HTTP connection with the web server and sit passively by while UIWebView drives the HTTP protocol. You then snoop on the incoming data before passing it on to UIWebView from your proxy. That would avoid the need to buffer the whole page in an NSString before feeding it to your UIWebView.

MPMoviePlayerController thumbnail images issue

We have a http live streaming running on our iOS app. We want to get thumbnail images every 1 minute. I tried using MPMoviePlayerController methods
thumbnailImageAtTime:timeOption:
and
requestThumbnailImagesAtTimes:timeOption:
But both these options return nil. The documentation doesn't say if these methods do not work for http live streaming. Any ideas what could be the issue?
Now documentation for this method says:
"This method is not not called when the source URL is an HTTP Live Streaming (HLS) content source. See HTTP Live Streaming Overview."
Try registering for MPMoviePlayerThumbnailImageRequestDidFinishNotification before calling this method and on getting notification check value of this key MPMoviePlayerThumbnailImageKey. In case image capture was successful value of this key will contain a valid UIImage for you to use.

Handling 404 error problems in the WebView Delegate in iPhone sdk

I am working with WebView based application, in that I had a problem with http 404 errors when I tried to load an url. I just want to show an alert when this happens. Can you guys please suggest me that how to trigger it and is there are any delegate methods fired when this happens?. Please suggest.
Thanks in adv,
S.
You can not check the status code for UIWebView requests. I rarely use webviews to do requests and when I do I don't care what the status codes are. I usually use NSURLConnection or ASIHTTPRequest to do requests. If you have to know the status of the http request, then do it using an NSURLRequest object and set the delegate to receive the response status code.

NSURLConnection "lost network connection" error?

I am developing an app that will upload the image from the iphone to a server. In server side there is a php program to handle the uploaded image. I am using the NSURLConnection with the Post method and have set the post body of the request. When I upload the image, I could see the image uploaded 3 times(in the server), but after sometime didFailWithError: is called stating that "lost network connection". What could be the reason for this? My doubt is that why is that image is uploaded multiple times? I have set the timeout of the request to 3600.0
Any help is appreciated.
Thanks
In my case, i have forgot to set method to POST like this:
[aRequest setHTTPMethod:#"POST"];
Hope it helps
How does your server respond to the upload? What status does it return to the client? If it accepts the image then resets the connection without replying to the POST request, you'll see the behaviour you've described.

iPhone Open DATA: Url In Safari

I have a Data: URL (see: http://en.wikipedia.org/wiki/Data_URI_scheme) (as a NSString) and I want to open it in Safari. How would you accomplish this (I tried openURL:.)
Example:
data:text/html;base64,(Some Base64 Encoded Data Here)
In iPhone OS 2.2.1 and 5.0.1, in both the simulator and on a device, opening a data: url works perfectly in a UIWebView but using openURL does precisely nothing.
And Safari will gladly, and properly, render such an URL if you are willing to type one into the navigation bar, so this is clearly a problem with sharedApplication openURL, not with Safari.
If the base64 string is short enough (less than 2K, probably) you could wrap it as a query parameter to an http URL that simply returns a redirect to the data url. Then you could use openURL to open the http URL. Yes, this means bouncing through some server, but it would work.
Alternatively, since Safari obviously hasn't done it, you could tell the iPhone that your app is the handler for the data: scheme and take responsibility for rendering the content in a UIWebView. This seems likely to fail in the future, though. :-)
Where is the data URL coming from in the first place? Perhaps you could construct a web page whose contents are nothing more than <iframe src="<the data url>"/> and again, use openURL on that URL.
This should do it:
NSURL *yourURL = [[NSURL alloc] initWithString:yourStr];
[[UIApplication sharedApplication] openURL:yourURL];
[yourURL release];
assuming "yourStr" is an NString with the URL where your data is located.