2013-05-31 23 views
1

我試圖阻止當用戶按下完成時退出MPMoviePLayerController中的視頻時發生的轉換動畫。我可以在電影完成後使用moviePlayBackDidFinish:notification完成,但由於某種原因,當我以與exitedFullscreen:notification完全相同的方式嘗試它時(它響應已完成的媒體),它無法正常工作,因爲它不起作用在動畫中出現。按下完成後無法停止在MPMoviePlayerController中發生的動畫

這裏是完整的代碼,任何幫助將不勝感激。

-(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]; 

} 
+0

調用setFullScreen:在removeFromSuperview之前生成動畫... [moviePlayer setFullscreen:NO animated:NO]; – R3D3vil

+0

我做了你所說的,但它沒有工作,我曾嘗試過,但它實際上是相同的代碼。我認爲它是一個蘋果bug,因爲沒有合理的理由說明它可以完美適用於moviePlayBackDidFinish:通知而不是exitedFullscreen:通知 – Gary

回答

0

您可以使用此代碼刪除動畫。

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


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


    } 


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

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

    } 
相關問題