Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block AirPlay Mirroring on iOS 5

On iOS 5 with an iPad 2 or iPhone 4S, users can enable screen mirroring with their Apple TV and AirPlay. How can I prevent my app from being mirrored in this way? Is there any way to detect that this mirroring is taking place so I can prevent my content from being mirrored?

The reason for doing this is because I have content I'm not legally allowed to display on a television screen.

like image 556
Carl Veazey Avatar asked Dec 07 '11 22:12

Carl Veazey


2 Answers

This is a really really bad idea and I hate it as you are inhibiting your users. With that said, AirPlay mirroring works the same way as connecting the VGA/HDMI adapter, when you connect an adapter you have the ability to display whatever you want on the "second monitor". If you want to "block" mirroring you could set the external display's window to a blank/solid black view.

Most iOS applications create and use only one window during their lifetime. This window spans the entire main screen of the device and is loaded from the application’s main nib file (or created programmatically) early in the life of the application. However, if an application supports the use of an external display for video out, it can create an additional window to display content on that external display. All other windows are typically created by the system, and are usually created in response to specific events, such as an incoming phone call.

Check out the View Programming Guide for iOS, specifically the Windows section and Displaying Content on an External Display

like image 97
Chris Wagner Avatar answered Sep 23 '22 15:09

Chris Wagner


Just to add the code for doing this pretty simple work Here

if ([[UIScreen screens] count] > 1)
    {
        UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
        CGRect screenBounds = secondScreen.bounds;
        UIWindow *secondWindow = [[UIWindow alloc]initWithFrame:screenBounds];
        secondWindow.screen = secondScreen;
        UIView *anyView= [[UIView alloc]initWithFrame:screenBounds];
        anyView.backgroundColor= [UIColor blackColor];
        [secondWindow addSubview:anyView];
    }
like image 23
Asadullah Ali Avatar answered Sep 21 '22 15:09

Asadullah Ali