I checked this in iOS beta 4 and this is for screen recording and airplay mirror as well.
I am able to capture the event for recording start and end. I added the KVO in "captured" property.
@property(nonatomic,readonly,getter=isCaptured) BOOL captured NS_AVAILABLE_IOS(11_0); // True if this screen is being captured (e.g. recorded, AirPlayed, mirrored, etc.)
UIScreen *mainScreen = [UIScreen mainScreen];
[mainScreen addObserver:self forKeyPath:@"captured" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription* currentRoute = audioSession.currentRoute;
for (AVAudioSessionPortDescription* outputPort in currentRoute.outputs){
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay]){
NSLog(@"%@",outputPort.portName);
NSLog(@"%@",outputPort.portType);
return;
}
}
if ([keyPath isEqualToString:@"captured"]) {
id oldC = [change objectForKey:NSKeyValueChangeOldKey];
id newC = [change objectForKey:NSKeyValueChangeNewKey];
NSLog(@"%d %d", [oldC boolValue], [newC boolValue]);
if (newC) {
/
}
}
}