iOS 11 Prevent Screen Record like Netflix

后端 未结 4 1422
失恋的感觉
失恋的感觉 2021-02-09 02:26

I have video playing in my application which I don\'t want to be recorded. What Netflix application do is that they let the audio capture but not the video whi

4条回答
  •  广开言路
    2021-02-09 03:07

    I create a black view and add it at the top of UIWindow. Then, in view controller of PlayerVideo, create the observer

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

    Then, in screenCaptureChanged:

    (void) screenCaptureChanged {
    if (@available(iOS 11.0, *)) {
        BOOL isCaptured = [[UIScreen mainScreen] isCaptured];
    
        if (isCaptured) {
            self.blackView.hidden = false;
        }
        else {
            self.blackView.hidden = true;
        }
    }
    

    }

    This solution will block the PlayerVideo when user is recording. However, I would like to create something like Netflix did. I want to let users do whatever they want while watching movie. If they are recording, they can continue watching video without black view. However, when they stop recording, the video will be save with black view. I'm still figuring out how Netflix did like this.

提交回复
热议问题