AirPlay Mirroring block on iOS 5

On iOS 5 with an iPad 2 or iPhone 4S, users can enable screen mirroring using Apple TV and AirPlay. How can I prevent mirroring of my application this way? Is there a way to detect that this mirroring is happening, so I can prevent my content from being mirrored?

The reason for this is that I have content that I am not allowed to allow on the TV screen.

+6
source share
2 answers

This is a really bad idea, and I hate it because you are banning your users. With that said, AirPlay mirroring works just like connecting a VGA / HDMI adapter, when you plug in the adapter, you can display whatever you want on the “second monitor”. If you want to “block” mirroring, you can set the external display window to a clean / solid black look.

Most iOS applications create and use only one window during their lifetime. This window covers the entire main screen of the device and is loaded from the main nib application file (or created programmatically) at an early stage of using the application. However, if an application supports the use of an external display for a video call, it may create an additional window for displaying content on that external display. All other windows are usually created by the system and are usually created in response to certain events, such as an incoming phone call.

Check out View the programming guide for iOS , specifically the Windows section and Display content on an external display.

+5
source

Just add code to do this pretty simple job.

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]; } 
+2
source

Source: https://habr.com/ru/post/903337/


All Articles