I want to block screen recording or video output per my app using QuickTime Player.
I had detected hdmi output and airplay with UIScreen
.
But QuickTime Play
Thus don't know detect QuickTime Player recording.
But I Found a solution with some trick.
If QuickTime Player recording is running, AVAudioSession's output portType has been changed to HDMIOutput.
So I coding as follows...(Swift 2.2)
func checkOutputPortType() {
let asRoute = AVAudioSession.sharedInstance().currentRoute
for output in asRoute.outputs {
if output.portType == AVAudioSessionPortHDMI {
// something you want..
}
}
}
Insert that function in ViewDidLoad and added AVAudioSessionRouteChangeNotification
notification.
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(checkOutputPortType), name: AVAudioSessionRouteChangeNotification, object: nil)
Thanks.