开发者

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开发者_StackOverflow中文版 *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];


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜