开发者

iOS - Force full screen video

I'm using a MPMoviePlayerViewController. When the video loads and starts playing it doesn't fill up the whole screen. I have to press the full screen button at the top right to make that happen. If I use MPMoviePlayerController I can't get it to fill the screen at all.

Any way via code that I can get my video full screen using the MPMoviePlayerViewController without having to press the fullscreen button?

I know i'm using a private API here, but thats ok, it is for a demo.

Code:

- (void)viewDidLoad
{
[super viewDidLoad];


[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"phatpad" ofType:@"mov"];

if (moviePath)
{
    NSURL *url = [NSURL fileURLWithPath:moviePath];
    player = [[MPMoviePl开发者_Python百科ayerViewController alloc]initWithContentURL:url];
}

player.view.frame = self.view.frame;

[self.view addSubview: player.view];

}

Here is a screen. The first is without pressing the full screen button, the second is after pressing it.

iOS - Force full screen video


You have to set the fullscreen attribute to true and the scallingMode to the aspect fill like this:

if (moviePath)
{
    NSURL *url = [NSURL fileURLWithPath:moviePath];
    player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
    player.moviePlayer.fullscreen = YES;
    player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
}

I have tested at home and it works, so I hope to you too.


On iPhones and iPod Touches, MPMoviePlayerController plays in full screen no matter what, so I'm assuming you're talking about an iPad? Can we please see some code samples? I can make mine full screen simply by resizing the UIView in my XIB file. How are you trying to do it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜