Enable or Disable Airplay

PDF for offline use:
Sample Code:
Related SDKs:

This recipe shows how to enable (or disable) AirPlay when playing a video using MPMoviePlayerController.


  • Add the following class variable in a UIViewController subclass.
MPMoviePlayerController moviePlayer;
  • Add a movie file named sample.m4v to the project in Xamarin or Visual Studio. There is a sample file included in the example project.
  • In the ViewDidLoad method, create the MPMoviePlayer
moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename("sample.m4v");
moviePlayer.View.Frame = View.Bounds;
moviePlayer.ShouldAutoplay = true; // starts automatically
  • To enable AirPlay for this movie, set AllowsAirPlay to true.
moviePlayer.AllowsAirPlay = true;
  • When the application runs, the AirPlay icon will be visible (the rectangle with the up-arrow, to the right of the movie controls). Pressing the AirPlay button will show a menu of available AirPlay devices – select another device and the video output will be routed to that device.

  • To disable AirPlay, set AllowsAirPlay to false and the AirPlay option will not be displayed.

moviePlayer.AllowsAirPlay = false;