MPMoviePlayerController全屏模式问题 [英] MPMoviePlayerController fullscreen mode issue
问题描述
我的代码播放视频文件时遇到问题。每当我以全屏模式播放文件时,播放都不会占用我的所有屏幕。以下是相关代码:
I have a problem with my code that plays a video file. Whenever I play the file in fullscreen mode the playback doesn't occupy all of my screen. Here is the relevant code:
NSURL *url = [NSURL fileURLWithPath:@"Somefile.mov"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[moviePlayer setFullscreen:YES];
moviePlayer.view.frame = self.switchView.frame;
[self.switchView addSubview:moviePlayer.view];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(playbackStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:moviePlayer];
[moviePlayer prepareToPlay];
[moviePlayer play];
这是我得到的输出:
推荐答案
选项A:改为使用 MPMovieViewController
并使用 presentMoviePlayerViewControllerAnimated:
以模态方式显示它。
Option A: Use the MPMovieViewController
instead and display it modally using presentMoviePlayerViewControllerAnimated:
.
选项B:确保你的switchView(你用来添加moviePlayer的视图)实际上占据了整个屏幕。
Option B: Make sure your switchView (which you use for adding the moviePlayer's view to) actually occupies the entire screen.
选项C:使用负垂直偏移重新调整moviePlayer视图的帧,直到它适合 - 例如: moviePlayer.view.frame = CGRectMake(0.0f,-20.0f,320.0f,480.0f);
Option C: Readjust the frame of the moviePlayer's view with negative vertical offsets until it fits - eg.: moviePlayer.view.frame = CGRectMake(0.0f, -20.0f, 320.0f, 480.0f);
注意:MPMoviePlayerController 始终在使用控件样式时显示状态栏 MPMovieControlStyleFullscreen
,无论你的应用程序的其余部分如何处理状态栏。
Note: MPMoviePlayerController always displays a status bar when using the control style MPMovieControlStyleFullscreen
, no matter how the rest of your app handles the status-bar.
这篇关于MPMoviePlayerController全屏模式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!