Enable or Disable Airplay
- PDF for offline use
- Sample Code:
- Related SDKs:
Let us know how you feel about this
This recipe shows how to enable (or disable) AirPlay when playing a video using MPMoviePlayerController.
- Add the following class variable in a
- 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.
- Ensure that the Build Action property of the file is set to Content.
- In the
ViewDidLoadmethod, create the
moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename("sample.m4v"); moviePlayer.View.Frame = View.Bounds; moviePlayer.ShouldAutoplay = true; // starts automatically moviePlayer.PrepareToPlay (); //required to enable the control to start playing
- To enable AirPlay for this movie, set
moviePlayer.AllowsAirPlay = true;
- To disable AirPlay, set
moviePlayer.AllowsAirPlay = false;