プレイ誤差にMPMoviePlayerViewControllerを消します
-
26-09-2019 - |
質問
私はMPMoviePlayerViewControllerに問題があります。コントローラは指定されたURLで映画を見つけることができない場合には、白い画面を表示し、私はそれが近くに行くことはできません。
。これは私がムービープレーヤーを起動する方法です
- (void) playVideo:(NSString*)path
{
NSURL* url = [NSURL URLWithString:path];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
double osversion = [[[UIDevice currentDevice] systemVersion] doubleValue];
if (osversion >= 3.2)
{
mplayerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
if (mplayerVC)
{
mplayerVC.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[mplayerVC.moviePlayer play];
mplayerVC.moviePlayer.shouldAutoplay = TRUE;
[self presentMoviePlayerViewControllerAnimated:mplayerVC];
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
}
}
}
これがどのようにmoviePlayBackDidFinish:このような方法に見える。
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
NSError* error = [[notification userInfo] valueForKey:@"error"];
if (error != nil)
{
// Movie ended with an error
DLog(@"error=%@", error);
}
else
{
// Movie ended successfully
}
[self dismissMoviePlayerViewControllerAnimated];
SAFE_DEL(mplayerVC);
}
URLは、間違っを指している場合は、白い画面にのみ発生します
解決
人を気にしないで、私はそれを考え出します。
どうやらあなたは、
呼び出す必要がありmoviePlaybackDidFinish方法で[player stop];
コントローラを却下する前に、
以上、プレイヤーはこのようにして得られたMPMoviePlayerControllerオブジェクトです。
MPMoviePlayerController *player = [notification object];
所属していません StackOverflow