【问题标题】:iOS detect/block screen recording using QuickTime playeriOS 使用 QuickTime 播放器检测/阻止屏幕录制
【发布时间】:2016-08-02 07:09:25
【问题描述】:

我想使用 QuickTime Player 阻止每个应用程序的屏幕录制或视频输出。

我用UIScreen 检测到 hdmi 输出和播放。 但是没有检测到 QuickTime Player 视频录制。

如何检测 QuickTime Player?

谢谢。

【问题讨论】:

    标签: ios quicktime screen-recording


    【解决方案1】:

    因此不知道检测 QuickTime Player 录制。

    但我找到了一个有技巧的解决方案。

    如果 QuickTime Player 正在录制,则 AVAudioSession 的输出端口类型已更改为 HDMIOutput。

    所以我编码如下......(Swift 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)
    

    谢谢。

    【讨论】:

      【解决方案2】:

      在 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{
      
          }
      }
      

      【讨论】:

      • 不适用于 AppKit/MacOS,有什么想法吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-05
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 2022-08-07
      相关资源
      最近更新 更多