按下完成后,无法停止在MPMoviePlayerController中发生的动画

时间:2013-05-31 15:47:25

标签: ios mpmovieplayercontroller animated

我正在尝试阻止当用户按下完成后退出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];

} 

1 个答案:

答案 0 :(得分:0)

您可以使用此代码删除动画。

 -(void)moviePlayBackDidFinish: (NSNotification*)notification
    {


      [moviePlayer stop];
      [moviePlayerController.view removeFromSuperview];
      moviePlayer = nil;


    }


    - (void)exitedFullscreen:(NSNotification*)notification {

        [moviePlayer stop];
        [moviePlayerController.view removeFromSuperview];
        moviePlayer = nil;

    }