我试图阻止在用户按下完成时退出 MPMoviePLayerController 中的视频时发生的过渡动画。当电影使用moviePlayBackDidFinish:通知自行完成时,我可以很好地停止它,但是由于某种原因,当我使用exitedFullscreen:通知(响应完成按下)以完全相同的方式尝试它时,它不起作用,因为在,动画发生。
这是完整的代码,任何帮助将不胜感激。
-(void) playvideo
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"test" ofType:@"MOV"]];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
self.navigationController.navigationBar.frame = CGRectMake(0, 0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
moviePlayer.fullscreen = YES;
}
-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
moviePlayer.fullscreen = NO;
[moviePlayer.view removeFromSuperview];
}
- (void)exitedFullscreen:(NSNotification*)notification {
moviePlayer.fullscreen = NO;
[moviePlayer.view removeFromSuperview];
}