Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.

id title brief samplecode sdk dateupdated
Play a Video Using MPMoviePlayerController
This recipe shows how to play a video using an MPMoviePlayerController.

ℹ️ Note: The MPMoviePlayerController class has been deprecated in iOS 9 and later. Use AVPictureInPictureController or AVPlayerViewController instead. Please see our Picture in Picture documentation.


  1. Add a class variable for an MPMoviePlayerController.
MPMoviePlayerController moviePlayer;
  1. Add code to play a movie. The following code does this in a UIButton’s TouchUpInside event handler:
playMovie.TouchUpInside += delegate {
    moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename ("sample.m4v"));

    View.AddSubview (moviePlayer.View);
    moviePlayer.SetFullscreen (true, true);
    moviePlayer.Play ();
} ;
  1. Ensure that any video files you intend to use are set with Build Action Content. You can do this by right-clicking on the video files and selecting **Build Action** in the context menu that appears.