iosmpmovieplayercontrollermovievideo-player

Play video in app instead of default player


I use the following code to play videos:

MPMoviePlayerViewController *theMovie=
    [[MPMoviePlayerViewController alloc] initWithContentURL: movieURL];
    theMovie.moviePlayer.repeatMode=MPMovieRepeatModeOne;

[self presentMoviePlayerViewControllerAnimated:theMovie];

This causes a the default movie player to cover the app. Instead I want the video to play inside the app itself as follows:

Can this be achieved?


Solution

  • You can set its frame like this:

    theMovie.view.frame = CGRectMake(10, 10, 300, 300);
    

    Then without presenting it add it as subview:

    [self.view addSubview: theMovie.view];
    

    Hope this helps.. :)