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

README.md

id title brief samplecode sdk dateupdated
23E8C6E6-E690-A11D-EA70-2E52E9CF1D4E
Play a Video Using MPMoviePlayerController
This recipe shows how to play a video using an MPMoviePlayerController.
2017-03-02

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

Recipe

  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.