3

iOSアプリでビデオを再生するためにMoviePlayerコントローラーを使用しています。私はこのようなオリエンテーション通知を使用しています

if(deviceOrientation ==UIDeviceOrientationLandscapeLeft)

{
     NSLog(@"Replay is in Landscape");

     self.fullScreenFlag = YES;

     [self.moviePlayer setFullscreen:YES animated:NO];

}

これにより、ユーザーが電話を横向きにしたときに、ビデオ画面が全画面で再生されます。しかし、moviePlayerコントロールの完了ボタンを押すと、次の方法に入ります

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

 UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;

if(deviceOrientation ==UIDeviceOrientationLandscapeLeft)  {
    NSLog(@"Pressed Done in Landscape");
    //Problem: Here I want to force my VideoViewController to rotate back to portrait  Mode
  }
}

ユーザーが完了ボタンを押すか、ビデオの再生が停止するとすぐに、VCをポートレートに戻す方法がわかりません。私はmoviePlayerNotificationMethodsを知っていますが、オリエンテーションのためにこれらのメソッドで何を呼び出すべきかが明確ではありません。

4

3 に答える 3

2

この問題は、ビデオ再生用に別のViewControllerを用意することで解決しました。

したがって、2つのビューコントローラがあります

  • SomeViewController
  • MoviePlayerViewController

SomeViewControllerで、ムービーを再生する場合:

MoviePlayerViewController *vc = [[MoviePlayerViewController alloc] initWithNibName:@"MoviePlayerViewController" bundle:nil];
[vc setPathToMovie:path];
[self.navigationController pushViewController:vc animated:YES];
[vc release];

そして、MoviePlayerViewControllerで

- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
    [[self navigationController] popViewControllerAnimated:YES];    
}

次に、SomeViewControllerを縦向きにロックダウンできます。ユーザーがビデオを見ているときに横向きになっている場合は、SomeViewControllerに戻ると縦向きに戻ります。

deviceOrientationメソッドとモーダルMPMoviePlayerControllerを使用した解決策は見つかりませんでした。でもあるかもしれません!

于 2013-01-17T22:47:38.477 に答える
0

「moviePlayBackDidFinish」でこれを行うことでこれを解決しました

  UIViewController* forcePortrait = [[UIViewController alloc] init];
  [self presentViewController:forcePortrait animated:NO completion:^{
  [forcePortrait dismissViewControllerAnimated:NO completion:nil];
  }];

美しくはありませんが、魅力のように機能します:-)

于 2014-01-09T10:38:32.823 に答える