0

我将 MPMoviePlayerController 放置在我的视图中的某个大小和位置。这工作正常。但是,在某些情况下,我希望视频全屏播放。我的视图是 UISPlitViewController 的一部分,所以如果我只是获得视图宽度,它就不是全屏的。我需要的是显示视频,就好像用户单击了播放器控件中的双端箭头以最大化视频一样。

到目前为止,这是我的代码。任何人都可以填写强制全屏播放的缺失位吗?

- (void)viewDidLoad
{
    [super viewDidLoad];

    // FIND OUT HOW MANY VIDEOS ARE AVAILABLE
    int videoCount = [[self videos] count];

    // GET THE FILE NAME OF THE FIRST AVAILABLE VIDEO
    NSString* fileName = [NSString stringWithFormat:@"%@.mp4", [self videos] objectAtIndex:0]];
    NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [arrayPaths objectAtIndex:0];
    NSString *filePath = [path stringByAppendingPathComponent:fileName];
    NSURL *url = [NSURL fileURLWithPath:filePath];

    // PLACE THE MOVIE AT THE CORRECT LOCATION ON THE PAGE
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [[moviePlayer view] setFrame:CGRectMake(100, 100, 600, 360)];
    [[moviePlayer view] setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    [[self view] addSubview:moviePlayer.view];
    [moviePlayer play];

    if(videoCount == 1)
    {
        -- MAXIMISE THE VIDEO TO FULL SCREEN AND LANDSCAPE --
    }
}

谢谢

4

2 回答 2

0

根据 Apple 的文档,您只需将 `MPMoviePlayerController 设置为全屏显示:

[moviePlayer setFullscreen:YES animated:YES]

你试过这个吗?

于 2013-02-27T14:22:07.100 回答
0

请使用 MPMoviePlayerViewController 因为 MP4 文件。当你使用 MOV 然后工作完美!

MPMoviePlayerViewController *moviePlayerViewController;

-(void)PlayVedioController:(NSString*)videoUrl1
{
    NSURL    *fileURL    =   [NSURL URLWithString:videoUrl1];
    moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];

    // Register for the playback finished notification.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(myMovieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayerViewController.moviePlayer];

    //Present
    [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

    // Play the movie!
    moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
    [moviePlayerViewController.moviePlayer play];
}

-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:moviePlayerViewController.moviePlayer];

    [moviePlayerViewController release], moviePlayerViewController = nil;
}
于 2013-05-31T11:07:36.797 回答