1

いくつかのページを含む tabBarViewController と loginViewController があります。[window addSubView:] を使用してビューを追加します。

フルスクリーン ビデオを再生する必要がある場合、ビデオを表示するためにウィンドウ内のすべてのビューを削除する必要があります。そうしないと、単なる黒い画面になります。ビデオがフルスクリーンで停止/終了/終了すると、サブビューを手動でウィンドウに再度追加する必要があります。

私はこれが間違ったやり方であることを知っています。このようにしないと、ビデオが全画面表示に切り替わると、ルート ウィンドウ ビューで他のビューの後ろに表示されます。

アドバイスをお願いします。ありがとうございました。

以下は私のコードです:

-(void)playMovie:(NSString *)urlStr{
NSURL *fileURL = [NSURL URLWithString:urlStr];
player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
player.scalingMode = MPMovieScalingModeAspectFit;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];    
[[appDelegate loginViewController].view removeFromSuperview];
[[appDelegate tabBarController].view removeFromSuperview];
[[appDelegate navController].view addSubview:player.view];
player.fullscreen = YES;
[player play];

}

- (void)willExitFullscreen:(NSNotification*)notification {
NSLog(@"willExitFullscreen...");
[[appDelegate window] addSubview:[appDelegate navController].view];
[[appDelegate window] addSubview:[appDelegate loginViewController].view];
[[appDelegate window] addSubview:[appDelegate tabBarController].view];
[player.view removeFromSuperview];

}

4

1 に答える 1

0

プレーヤーを表示するには、次を使用します。

[self presentMoviePlayerViewControllerAnimated:player]; 
//Self should be a View Controller.

を使用するのではなくaddSubview

また、( 経由でアクセスできますmovieSourceType)に を設定し、推奨事項として、点滅する白い背景を避けるために を使用してプレーヤーの背景を設定する必要があります。playerplayer.moviePlayerplayer.view.backgroundColor = [UIColor blackColor];

于 2012-06-15T03:32:49.280 に答える