How can I turn on AirPlay Screen Mirroring on the iPhone 4S programmatically

Mike Ullrich picture Mike Ullrich · Jan 9, 2012 · Viewed 8.8k times · Source

I have written an app for iPhones and for the 4S I want to support screen mirroring of the application over AirPlay.

Using the System AirPlay picker the and with Mirroring turned on it will mirror the app without any issues.

I would like to offer this picker in the app and have used the following basic code:

MPVolumeView *volumeView = [ [MPVolumeView alloc] init] ;
[volumeView setShowsVolumeSlider:NO];
[volumeView sizeToFit];
[self.view addSubview:volumeView];

This provides an AirPlay picker and I can select the Apple TV. However it does not mirror the content over AirPlay. When I go to the system picker it shows that the AppleTV is selected, and to enable mirroring I have to use the switch here.

So the question is, how can I turn on mirroring in the app when a user selects AirPlay using the app picker?

Thanks

Answer

justice picture justice · Apr 24, 2012

The only way to programmatically enable mirroring is to use private APIs. See here