Technical Q&A QA1738

How to opt out of video mirroring

Q:  How do I opt out of video mirroring when using the Apple Digital AV Adapter with a compatible iOS device?

A: On compatible devices, iOS will automatically mirror the display when an external screen is attached. If you do not wish your application's contents to be mirrored, your application must present alternate content on the external display in place of the default content. To do so, use the normal process for displaying content on an external display as described in Displaying Content on an External Display in the View Programming Guide for iOS.

We recommend you display appropriate content so the user isn't simply greeted by a black screen. For example, show auxiliary information about the video, or at minimum, a static image or suitable text ("Video mirroring is not supported by this application" or similar).

The ExternalDisplay sample code also demonstrates how to detect the presence of an external display, determine the available display resolutions, select a resolution, and show content on the display.

For example, to determine if the display is being mirrored, use the respondsToSelector method on the screen object to see if it responds to the mirroredScreen property as shown in Listing 1.

Listing 1  Using the mirroredScreen property to determine if the display is being mirrored.

UIScreen *aScreen;

NSArray *screens = [UIScreen screens];
for (aScreen in screens) 
{
    if ([aScreen respondsToSelector:@selector(mirroredScreen)] 
              && [aScreen mirroredScreen] == [UIScreen mainScreen]) 
    {
        // The main screen is being mirrored.
    }
    else 
    {
        // The main screen is not being mirrored, or
        // you are not running on a compatible device.
    }
}


Document Revision History


DateNotes
2011-04-04

New document that describes how to opt out of video mirroring.