How do I know if screen recorder is Turned ON.

My applicaiton requires content not to be copied, and I have already blocked it from Ariplay/HDMi, Quicktime, but how do I stop it form screen recorder on iOS 11. I need a wasy to detect if screen recording is turned ON from control center.... Please help...

Answered by RyotzIwatz in 247434022

Use this UIScreen's new propertiy in iOS11 beta 4 `isCaptured`.

https://developer.apple.com/documentation/uikit/uiscreen/2921651-iscaptured

It is works well in beta4.

try it if you need to build with xcode8

BOOL isCaptured = NO;

@try

{

isCaptured = [[[UIScreen mainScreen] valueForKey:@"isCaptured"] boolValue];

}

@catch (NSException * e) {

}

Did you get this to compile? Properties unrecognized by the Xcode 8.3.3 compiler will throw fatal errors.


Wrapping the iOS 11 specific code like this will allow compiling on prior versions of Xcode that do not know about iOS 11:


#ifdef __IPHONE_11_0

...

//Wrapping iOS 11 methods and properties in this if statement will allow Xcode to compile to earlier iOS versions:

if (@available(iOS 11_0, *)) {

...

}

...

#endif


This technique successfully handles detection for iOS 11 when compiled in Xcode 9 and still allows support of earlier OS's.

Hi Guys,

We work on HLS+Fairplay, and found isCaptured can not be observerd in playback Fairplay content.

Nevertheless, if play clear content, it can work.


Could anyone have idea to workaround this issue?


We know even it can be recorded but just black screen, but we focus on better ux, want to show dialog

to remind user can not record video content


Code snippet :

[[UIScreen mainScreen] addObserver:self forKeyPath:@"captured" options:NSKeyValueObservingOptionNew context:nil];

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
     // observe well when play clear content, but failed in HLS+FairPlay (Please note video should be playback, it can work before ckc verified)
    if ([keyPath isEqualToString:@"captured"]) {
        BOOL isCaptured = [change[NSKeyValueChangeNewKey] boolValue];
       //blablabla
    }

}


Another notification still can not get event in fairplay mode


[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(screenDidChangeNotification:) name:UIScreenCapturedDidChangeNotification object:nil];

isCaptured is a UIScreen property, specific to each screen - main or attached. Are you saying that Fairplay is overriding the access to this property on all of the screens?


I haven't tried recording an external screen, but have had success detecting all changes to this property with the main screen [UIScreen mainScreen]. And I check every screen in the screens array prior to playback operations to see if its isCaptured is set.

Hi robvandy55,


Sorry for my not clear expression, there is key point I should describe.


1. Play FairPlay content (Make sure it can play / pause )

2. Go back background, enable "Screen Record"

3. Immediately back to FairPlay player page (You must be fast than record countdown number, eg: earlier than 3 seconds)

4. Polling to get isCapured value, it always return false


5. Go back background againg, and do nothing.

6. back to FairPlay Player page, isCaptured will return true


Thank you~

Not sure why are you trying this..

  1. if ([keyPath isEqualToString:@"captured"]) {
  2. BOOL isCaptured = [change[NSKeyValueChangeNewKey] boolValue];
  3. //blablabla
  4. }



In my case, I am checking the property directly as soon as I get notification, and getting the correct value, by using:

[[[UIScreen mainScreen] valueForKey:@"captured"] boolValue]


And also add notificaiton for NSKeyValueObservingOptionOld value too, as:

[[UIScreen mainScreen] addObserver:self forKeyPath:@"captured" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];

isCaptured is not working properly when user tries to stop the screen share from top left red icon from outside the app, it gives before taking the input screen share popup.

anyone has any idea ?

How do I know if screen recorder is Turned ON.
 
 
Q