Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPMoviePlayerViewController protected URL from yahoo hosted site using setDefaultCredential

I am using similar code as mentioned in MPMoviePlayerViewController documentation. But it's not working. It says "you are not authorized..". My server is hosted on Yahoo. Url is something like this.

Code is below

NSURLCredential *credential = [[NSURLCredential alloc] 
                           initWithUser:@"abc" 
                           password:@"xyz"
                           persistence: NSURLCredentialPersistencePermanent];

 NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
                                     initWithHost:@"www.someurl.com"
                                     port:80
                                     protocol:@"http"
                                     realm:@"tmp"

   authenticationMethod:NSURLAuthenticationMethodDefault];

[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential
                                                forProtectionSpace:protectionSpace];

 [protectionSpace release];
 [credential release];
  MPMoviePlayerViewController *movie = [[[MPMoviePlayerViewController alloc] initWithContentURL:url] autorelease];
like image 295
okgo Avatar asked Mar 22 '11 21:03

okgo


1 Answers

If this is the same as the UIWebView access you would first open up an NSURLConnection and pass the credential in the relevant delegate methods then once you get a response you cancel the connection and then start the MPMoviePlayerViewController with the connection.

like image 133
user3061915 Avatar answered Oct 16 '22 16:10

user3061915