我試圖播放託管在我的服務器上的視頻。我一直在尋找一段時間,我還沒有解決這個問題。我正在嘗試使用NSURLCredential。MPMoviePlayer播放受保護的網址播放流
這裏是我的代碼:
-(MPMoviePlayerController *)moviePlayerController
{
NSURL *url = [NSURL URLWithString:@"http://ABCd.com/secret/MOVIE.mov"];
NSURLCredential *credential = [[NSURLCredential alloc]
initWithUser: @"username"
password: @"password"
persistence: NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
initWithHost: [url host]
port: 80
protocol: [url scheme]
realm: nil
authenticationMethod: NSURLAuthenticationMethodHTTPBasic];
[[NSURLCredentialStorage sharedCredentialStorage]
setDefaultCredential: credential
forProtectionSpace: protectionSpace];
_moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
}
當使用moviePlayerBackDidFinish:(NSNotification *)通知 我收到以下錯誤
去把錯誤:錯誤域= MediaPlayerErrorDomain代碼= -1013「的操作無法完成(MediaPlayerErrorDomain error -1013。)「
任何想法?
歡迎SO使用
嘗試。您是否確認您已成功連接並獲得訪問權限? – sangony
是的,我確認了一個成功的連接。 – kcajmagic