I'm working on a video content app that has AirPlay capabilities. When it streams the video content over AirPlay (AVPlayer), the UI on the device would be a remote control for the player, but when AirPlay is set to mirror, it'll display the same interface on both devices as expected, since all I know is that AirPlay is connected, but I don't know whether it's mirroring or not. I use the following code to check for AirPlay connection:
- (BOOL)isAirPlayTVOutput {
return ([self isAirplayActive] && ![self isBluetoothOutputType]);
}
- (BOOL)isAirplayActive {
self.deviceOutputType = nil;
self.airplayDeviceName = nil;
AVAudioSessionRouteDescription *routeDescription = [[AVAudioSession sharedInstance] currentRoute];
for (AVAudioSessionPortDescription *portDescription in routeDescription.outputs) {
self.deviceOutputType = portDescription.portType;
self.airplayDeviceName = portDescription.portName;
if ([portDescription.portType isEqualToString:AVAudioSessionPortAirPlay]) {
return YES;
}
}
return NO;
}
How would I know if it's mirroring or not?
I could solve this by using the solution in this answer:
How to check if the device is connected via airplay?
Not the best solution, but probably the only available one.