6
我正在使用與MPMoviePlayerViewController
文檔中提到的類似的代碼。但它不起作用。它說「你沒有被授權..」。我的服務器託管在雅虎上。網址是一樣的東西this.MPMoviePlayerViewController使用setDefaultCredential從雅虎託管網站保護的URL
代碼如下
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];