私は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
このビデオは、ログインしているユーザーのみ閲覧可能ですので、動画のURLをパブリックユーザーによってアクセスされた場合、彼らはログインするHTMLフォームが提示されています。この場合、NSURLCredential
は機能しませんか?
ログインした資格情報(ビデオのダウンロードなど)を使用しているのに、MPMoviePlayerViewController
はこれらの同じ資格情報を使用していないように見えますが、ビデオの再生を拒否しますページ)?
解決方法はありますか?
+1いい質問です。一般に、MPMoviePlayerController(前者が頼りにしているAVPlayerと同じように)は、共有された高水準のネットワーキング機能をあまり利用していないようです。 – Till
私はiOSデベロッパーサポートチケットの1つを使用しており、Appleにこの質問を送っています。彼らが言うことを見るだろう。 –
これに関するニュース? – Till