我使用SOAP web service
登錄到我的服務器。登錄後,我正在查看的許多文件只能用於登錄用戶,因此iOS必須在NSURL
或其他內容中創建會話。iOS:播放需要身份驗證的視頻在QuickLook中播放,但不在MPMoviePlayerViewController中播放
當試圖使用MPMoviePlayerViewController
預覽視頻文件時,它不起作用,它只是加載viewController,然後將其解除。
如果我使用QuickLook
它不工作,可能是因爲我下載的視頻在本地,然後再查看。
但是,我不想這樣做,我想用MPMoviePlayerViewController
來流式傳輸視頻,因爲我不希望用戶不得不下載整個視頻文件。我看過有關使用NSURLCredential
的帖子,但這似乎不適用於我。我用(加入我自己的個人明顯的信息):
/**
* Play media session
*
* @version $Revision: 0.1
*/
- (void)playMediaWithURL:(NSString *)mediaURL {
// Authenticate
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"myusername"
password:@"mypassword"
persistence:NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
initWithHost:@"mysite.com"
port:80
protocol:@"http"
realm:nil
authenticationMethod:NSURLAuthenticationMethodDefault];
[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace];
// The movie player
NSURL *movieURL = [NSURL URLWithString:[mediaURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
MPMoviePlayerViewController *tempPlayer = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
// Add observer
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
// Properties
tempPlayer.moviePlayer.allowsAirPlay = YES;
tempPlayer.moviePlayer.shouldAutoplay = YES;
tempPlayer.moviePlayer.useApplicationAudioSession = NO;
[self presentMoviePlayerViewControllerAnimated:tempPlayer];
[tempPlayer.moviePlayer play];
}//end
因爲這個視頻只是一個登錄的用戶可見的,如果視頻的網址是由公共用戶訪問,他們都帶有HTML表單登錄。 NSURLCredential
在這種情況下不起作用嗎?
爲什麼所有撥打NSURLConnection
的電話都使用我登錄的憑據(例如下載視頻),但MPMoviePlayerViewController
似乎沒有使用這些相同的憑據,並拒絕播放視頻(可能是因爲它獲得登錄頁)?
有沒有解決方案?
+1好的問題 - 對答案好奇。一般來說,MPMoviePlayerController(就像前者所依賴的AVPlayer一樣)似乎沒有充分利用這種共享的高級網絡功能。 – Till 2012-03-21 09:45:59
我正在使用我的iOS開發支持門票之一,並將此問題發送給Apple。將看到他們說什麼.. – 2012-03-21 16:14:13
這一個的任何消息? – Till 2012-07-27 20:54:31