我正在使用MPMoviePlayerViewController
文档中提到的类似代码。但这不起作用。它说“您无权..”。我的服务器托管在Yahoo上。网址类似于this.
代码如下
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];
最佳答案
如果这与UIWebView访问相同,则您将首先打开NSURLConnection并在相关的委托(delegate)方法中传递凭据,然后一旦获得响应,便取消连接,然后使用该连接启动MPMoviePlayerViewController。