2013-07-04 3 views
0

iOS 앱을 개발 중이며 사용자가 버튼을 눌렀을 때 동영상을 재생하고 싶습니다. 이것을 개발했는데 사용자가 버튼을 누르면 비디오가 재생되지만 비디오가 끝나면 비디오의보기가 유지되고 비디오의 마지막 프레임에서 고정됩니다.iOS-Xcode : 비디오 복제가 마지막 프레임에서 고정되었습니다.

나는 구글에서 검색 한 나는이 질문을 발견 :

iOS 6, Xcode 4.5 video not exiting when done playing

나는 코드가 작성하지만 난 그것을 고정되지 않은 사용했다. 이 내 코드입니다 : 불편을 끼쳐 드려

-(IBAction)reproducirVideo:(id)sender 
{ 
NSURL *url5 = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
             pathForResource:@"instrucciones"  ofType:@"mp4"]]; 
_moviePlayer = [[MPMoviePlayerController alloc] 
        initWithContentURL:url5]; 

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

-(void) moviePlayBackDidFinish:(NSNotification *)aNotification{ 
[_moviePlayer.view removeFromSuperview]; 
_moviePlayer = nil; 
} 


- (void)moviePlayerWillExitFullscreen:(NSNotification*) aNotification { 
[_moviePlayer stop]; 
[_moviePlayer.view removeFromSuperview]; 
_moviePlayer = nil; 
} 

답변

1

미안하지만 난이 질문을 읽고 난 그냥 그것을 고정 :

- (IBAction)reproducirVideo:(id)sender 
{ 
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
            pathForResource:@"instrucciones" ofType:@"mp4"]]; 
_moviePlayer = 
[[MPMoviePlayerController alloc] 
initWithContentURL:url]; 

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

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

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

MPMoviePlayerController *player = [notification object]; 

[[NSNotificationCenter defaultCenter] removeObserver:self 
               name:MPMoviePlayerPlaybackDidFinishNotification 
               object:player]; 

if ([player 
    respondsToSelector:@selector(setFullscreen:animated:)]) 
{ 
    [player setFullscreen:NO animated:YES]; 
    [player.view removeFromSuperview]; 
} 
} 
:

MPMoviePlayerController will not automatically dismiss movie after finish playing (ios 6)

이 오른쪽 코드

고맙습니다. 너는 내 인생을 구했다.

감사합니다.