2017-01-11 13 views
0

나는 선택한 쇼에 대한 정보를 표시하는 ViewController가 있으며 MPMoviePlayerController의 재생 단추가 있습니다. 이제 문제는 내가 플레이어의 전체 화면을 클릭 한 다음 완료를 클릭했을 때입니다. 그것은 정보를 표시하는 ViewController로 돌아가는 것으로되어 있지만 그렇지 않습니다. 하지만 그것은 ViewController의 viewDidLoad에 들어가고 아무 것도 표시하지 않습니다. 뭔가 그MPMoviePlayerController 시청 후 동일한 ViewController로드

같이하여의 ViewController의 상단 또는 뭔가처럼 나는 당신은되지 않습니다 AVPlayerViewControllerMPMoviePlayerController로서 사용하는 플레이어 컨트롤러를

- (void)dealloc 
{ 
self.delegate = nil; 
self.activityIndicator = nil; 
[self deregisterMoviePlayerNotifications]; 
[self.player.view removeFromSuperview]; 
[self removeFromSuperview]; 
[self stopVideo]; 
self.player = nil; 
} 

답변

1

을 제거하는 방법은 다음과 생각합니다. 당신은 재생 버튼에

-(void)playButton{  
    AVPlayer *player = [[AVPlayer alloc]initWithURL:urlVideo]; 
    AVPlayerViewController *controller = [[AVPlayerViewController alloc]init]; 
    controller.player = player; 
    controller.videoGravity = AVLayerVideoGravityResizeAspectFill; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:player.currentItem]; 
    controller.videoGravity = AVLayerVideoGravityResizeAspect; 
    [self presentViewController:controller animated:YES completion:nil]; 
    [player play]; 
} 

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

    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

참고이 코드를 사용할 수 있습니다 : AVFoundation.framework를 추가하는 것을 잊지 마십시오.