2016-08-02 16 views

答えて

3

このように、QuickTime Playerの記録を検出することはできません。

しかし、私はいくつかのトリックで解決策を見つけました。

QuickTime Playerの録画が実行されている場合、AVAudioSessionの出力ポートタイプは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) 

ありがとうございます。あなたはAppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 

    NotificationCenter.default.addObserver(self, selector: #selector(checkIFScreenIsCapture), name: NSNotification.Name.UIScreenCapturedDidChange, object: nil) ...... 

使用セレクタに通知

NSNotification.Name.UIScreenCapturedDidChange 

を使用することができますiOSの11で

0

func checkIFScreenIsCapture(notification:Notification){ 
    guard let screen = notification.object as? UIScreen else { return } 
    if screen.isCaptured == true { 

    }else{ 

    } 
} 
関連する問題