views:

273

answers:

1

Hi all,

i am trying to play a video from my IIS, which is protected with basic authentication. Can any one help with how to play an video with authentication.

MPMoviePlayerController has only these parameters.

contentURL property
backgroundColor property
scalingMode property
movieControlMode property

how to give auth details?? can any one help me out with this...

thanks

A: 

The contentURL property is an instance of class NSURL which can hold among other things user and password, per RFCs 2396, 1738, 1808. So, per those URLs, use, in the initWithString call with which you build the NSURL instance, a string such as:

http://theusername:[email protected]/path/to/the/video

and this should take care of your basic auth needs!

Alex Martelli
But it is not the safest way sir...every one can see the username and password...
nbojja
Absolutely, that's the curse of HTTP -- nothing is hidden. If you DO need hiding, you must switch to HTTPS. A better, stronger system than basic auth, which is well-known to be quite fragile, is also advisable, if your content is very precious and worth protecting. However, as usual when you tighten security, better security comes at the expense of convenience and functionality -- e.g., I don't think the controller you want to use supports anything BUT basic HTTP auth with user and password in the NSURL instance. So, if you need stronger security, no using that controller, I think.
Alex Martelli
IOW, @nbojja, it IS the safest way... the safest way I know to use the specific controller you want to use (except that HTTPS is an improvement if you buy a valid cert for your server). If that controller has undocumented better ways, and you discover them, be careful against using them in your iPhone apps, as Apple's policy is to reject apps using undocumented APIs!-)
Alex Martelli