我想使用QuickTime Player阻止每個應用的屏幕錄製或視頻輸出。使用QuickTime播放器的iOS檢測/屏蔽屏幕錄製
我用UIScreen
檢測到hdmi輸出和airplay。 但QuickTime Player的視頻錄製沒有檢測到。
如何檢測QuickTime Player?
謝謝。
我想使用QuickTime Player阻止每個應用的屏幕錄製或視頻輸出。使用QuickTime播放器的iOS檢測/屏蔽屏幕錄製
我用UIScreen
檢測到hdmi輸出和airplay。 但QuickTime Player的視頻錄製沒有檢測到。
如何檢測QuickTime Player?
謝謝。
因此不知道檢測QuickTime Player的錄音。
但我找到了一些解決方案。
如果QuickTime Player錄音正在運行,AVAudioSession的輸出portType已更改爲HDMIOutput。
所以我編碼如下...(雨燕2.2)
func checkOutputPortType() {
let asRoute = AVAudioSession.sharedInstance().currentRoute
for output in asRoute.outputs {
if output.portType == AVAudioSessionPortHDMI {
// something you want..
}
}
}
插入,在viewDidLoad中發揮作用,並添加AVAudioSessionRouteChangeNotification
通知。
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(checkOutputPortType), name: AVAudioSessionRouteChangeNotification, object: nil)
謝謝。
與iOS 11,你可以使用通知
NSNotification.Name.UIScreenCapturedDidChange
上AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
NotificationCenter.default.addObserver(self, selector: #selector(checkIFScreenIsCapture), name: NSNotification.Name.UIScreenCapturedDidChange, object: nil) ......
使用選擇
func checkIFScreenIsCapture(notification:Notification){
guard let screen = notification.object as? UIScreen else { return }
if screen.isCaptured == true {
}else{
}
}