我遇到了从带有基本HTTP身份验证的URL播放电影的问题。
这是代码:
NSURLCredential *credential = [[NSURLCredential alloc]
initWithUser:@"user"
password:@"password"
persistence:NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
initWithHost:@"moze.dyndns.org"
port:80
protocol:@"http"
realm:nil
authenticationMethod:NSURLAuthenticationMethodHTTPBasic];
[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace];
NSURL *videoURL = [NSURL URLWithString:@"http://moze.dyndns.org/test/test.mov"];
moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[moviePlayerController.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayerController.view];
MPMoviePlayerController *mp = [moviePlayerController moviePlayer];
mp.controlStyle = MPMovieControlStyleDefault;
[mp prepareToPlay];
[[moviePlayerController moviePlayer] play];
我遇到了一个错误:“操作无法完成。(MediaPlayerErrorDomain错误-1013.)”,错误日志为NULL,访问日志也是如此。
我正在使用带有AuthType Basic的Apache服务器,凭据是正确的,在Web浏览器上测试过。如果禁用身份验证,没有播放问题。
请帮忙解决,我找不出问题所在。