0
votes

I am placing an MPMoviePlayerController in my view at a certain size and position. This is working fine. However, in certain circumstances, I want the video to play full screen. My view is part of a UISPlitViewController, so if I just get the view width, it is not full screen. What I need is to show the video as if the user had clicked the double ended arrow in the player controls to maximise the video.

Here is my code so far. Can anyone fill in the missing bit that forces the full screen playing?

- (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 --
    }
}

Thanks

2

2 Answers

0
votes

As per Apple's documentation, you just have to set the `MPMoviePlayerController to go full screen:

[moviePlayer setFullscreen:YES animated:YES]

Have you tried this?

0
votes

Please use MPMoviePlayerViewController Because of MP4 file. When you use MOV then working perfect!!

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;
}