moviePlayer - 完成播放后出现黑屏

时间:2014-05-10 10:54:45

标签: ios7 mpmovieplayercontroller

我遇到的问题是当我按完成按钮或电影完成播放时会出现黑屏。我想回到我放置UIImage的开始屏幕。

-(void)playMovie:(id)sender
{

    NSString * str=[[NSBundle mainBundle]pathForResource:@"yo2" ofType:@"mov"];
    NSURL * url=[NSURL fileURLWithPath:str];
    MPMoviePlayerController * movieController=[[MPMoviePlayerController alloc]initWithContentURL:url];
    movieController.controlStyle=MPMovieControlStyleFullscreen;
    [movieController.view setFrame:self.view.bounds];
    [self.view addSubview:movieController.view];
    [movieController prepareToPlay];
    [movieController play];
    _moviePlayer =  [[MPMoviePlayerController alloc]
                     initWithContentURL:url];


    _moviePlayer.controlStyle = MPMovieControlStyleDefault;

    _moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:_moviePlayer.view];
    [_moviePlayer setFullscreen:YES animated:YES];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:_moviePlayer];


}



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

    // Remove observer
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:nil];
    [self dismissViewControllerAnimated:YES
                             completion:^{
                                 [self performSegueWithIdentifier:@"back" sender:self];
                             }];

}

@end

0 个答案:

没有答案