2012-12-20 4 views
6

MPMoviePlayerControllerプレーヤーボタンは、完了ボタンを押した後も永久に隠れます。MPMoviePlayerController:プレイヤーコントロールをプレイヤーコントロールを隠すだけで、iOS6を吹き飛ばします。

moviePlayer.controlStyle = MPMovieControlStyleEmbeddedの埋め込みプレーヤーがあります。ユーザーがmoviePlayerDidEnterFullscreen通知でフルスクリーンモードをタップすると、[moviePlayer setFullscreen:NO]を作成しています。そして、風景モード

moviePlayer.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); 

と私が行っボタンを上タップすると次に

moviePlayer.controlStyle = MPMovieControlStyleFullscreen; 

を設定し、moviePlayBackDidFinishに私はポートレートモードに戻すビューを変換していますし、組み込みにcontrolStyleを設定するプレーヤーのビデオを変換します。これまでのところうまく動作しています。その後、ビデオが一時停止され、再生ボタンをタップすると再生が始まり、プレーヤーはしばらくの間滞在し、永久に隠れる。ビデオをテーピングした後、プレーヤーは表示されなくなります。私は遅延の後に埋め込みにプレーヤーコントロールを設定しようとしました。何も働いていません。この問題で助けてください。

この問題はのみのiOS 6

コード

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

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(moviePlayerDidEnterFullscreen:) 
              name:MPMoviePlayerDidEnterFullscreenNotification 
              object:nil]; 


if (mpVideoPlayerController) 
{ 
    [mpVideoPlayerController.moviePlayer pause]; 
    [mpVideoPlayerController.moviePlayer stop]; 
} 


mpVideoPlayerController = nil; 
mpVideoPlayerController = [[VideoPlayerViewController alloc] initWithContentURL: theURL]; 


mpVideoPlayerController.moviePlayer.movieSourceType = liveStreaming ? MPMovieSourceTypeStreaming : MPMovieSourceTypeUnknown; 

if ([mpVideoPlayerController.moviePlayer respondsToSelector:@selector(setAllowsAirPlay:)]) { 
    mpVideoPlayerController.moviePlayer.allowsAirPlay = YES; 
} 

[[mpVideoPlayerController.moviePlayer view] setFrame:viewInsetRect]; 
mpVideoPlayerController.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; 
mpVideoPlayerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
[viewController.view addSubview: [mpVideoPlayerController.moviePlayer view]]; 
[mpVideoPlayerController.moviePlayer play]; 
} 


-(void) moviePlayerDidEnterFullscreen :(NSNotification*)notification { 
    [mpVideoPlayerController.moviePlayer setFullscreen:NO]; 
    [[UIApplication sharedApplication] setStatusBarHidden:YES]; 
    [self performSelector:@selector(setControlStyleFullscreen) withObject:nil afterDelay:0.2]; 
    [UIView animateWithDuration:0.3 
        animations:^{ 
         mpVideoPlayerController.moviePlayer.view.transform = CGAffineTransformIdentity; 
         mpVideoPlayerController.moviePlayer.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); 
         CGRect frame=[[UIScreen mainScreen] applicationFrame]; 
         frame.origin.y=-20; 
         mpVideoPlayerController.moviePlayer.view.frame = frame;//CGRectMake(0.0, 0.0, 480.0, 300.0); 
        } completion:^(BOOL finished) { 

        }]; 


} 

- (void) setControlStyleFullscreen 
     mpVideoPlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen; 

- (void) setControlStyleEmbedded 

     mpVideoPlayerController.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; 



- moviePlayBackDidFinish: 

    NSLog(@"moviePlayBackDidFinish:"); 

    [self rotateToInterfaceOrientation:UIInterfaceOrientationPortrait frameForView:(viewController).videoContentView.frame]; 

    [[UIApplication sharedApplication] setStatusBarHidden:NO]; 

    [self performSelector:@selector(setControlStyleEmbedded) withObject:nil afterDelay:0.2]; 
+1

使用しているMPmoviecontrollerの完全なコードを共有してください... – Vishal

+1

ありがとうございますVishal、コードを確認してください –

答えて

1

あなたのコードは一種の障害があり、それらのMPMoviePlayerControllerバグをトリガし、以下のバージョンです。

  • 余分なセットフルスクリーンはすでにフルスクリーンになっています。我々は一般的に

フルスクリーンコントロールのスタイルに既にあるよう

  • 余分setControlStyleは、すでに行われてMPMoviePlayerControllerに物事を強制することはありません。

    - (void)moviePlayerDidEnterFullscreen :(NSNotification*)notification 
    { 
        // 
        //remove both lines from this notification handler 
        // 
        [mpVideoPlayerController.moviePlayer setFullscreen:NO]; 
        [self performSelector:@selector(setControlStyleFullscreen) withObject:nil afterDelay:0.2]; 
        [...] 
    } 
    

    また、現在のモードを確認してsetControlStyleFullscreen/Embeddedの実装を拡張することもできます。それは変だと思われるかもしれませんが、それは多くの助けになります。

    - (void)setControlStyleEmbedded 
    { 
        if (mpVideoPlayerController.moviePlayer.controlStyle != MPMovieControlStyleEmbedded) 
        { 
         mpVideoPlayerController.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; 
        } 
    } 
    
    - (void)setControlStyleFullscreen 
    { 
        if (mpVideoPlayerController.moviePlayer.controlStyle != MPMovieControlStyleFullscreen) 
        { 
         mpVideoPlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen; 
        } 
    } 
    
  • 関連する問題