1

我的代码可以正确播放视频,但不能全屏播放。

-----------  
|_______  |  
|XXXXXXX| |  
|XXXXXXX| |    
-----------

它的大小大约是 X 字段区域的大小。
我在 ipad2 上运行它。

 NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"movie.mp4" ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:urlStr];
    videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(movieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:videoPlayer];
    [self.view addSubview:videoPlayer.view];
    [videoPlayer setFullscreen:YES];
    videoPlayer.view.frame = [[UIScreen mainScreen] bounds];  
    [videoPlayer play];    
    [super viewDidLoad];    
4

1 回答 1

2

将您的框架设置MPMoviePlayerController为 1024x768。

videoPlayer.view.frame = CGRectMake(0,0,1024,768); //748 if you have status bar.

希望这就是你要找的。*编辑:试试这种方式,这是我使用的一种。

UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[self.view addSubview:tempView];

playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"www.orangebob.com/files/movie.mp4"]];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(movieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:[playerViewController moviePlayer]];

playerViewController.view.frame = CGRectMake(0, 0, 1024, 768);
[tempView addSubview:playerViewController.view]; //This *fixes* it, but it's kinda dirty.



MPMoviePlayerController *player = [playerViewController moviePlayer];

[player play];
于 2012-08-15T18:03:19.510 回答