iOS 11 Prevent Screen Record like Netflix

后端 未结 4 1410
失恋的感觉
失恋的感觉 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 02:58

    You can listen for a UIScreenCapturedDidChange notification.

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

    This is called when iOS 11 screen recording begins and ends. When the user is recording the screen, you can modify the UI to block any content that you don't want recorded.

    This notification is fired when UIScreen's isCaptured property changes. You can also inspect this property yourself:

    UIScreen.main.isCaptured
    
    0 讨论(0)
  • 2021-02-09 03:01

    I believe, Netflix takes advantage of the "FairPlay Streaming" technology provided by Apple. According to Apple Documentation

    If your application uses FairPlay Streaming (FPS) your video content will automatically not be captured by the iOS 11 screen recording feature or QuickTime Player on macOS. The portion of your application that is playing the content will be blacked out.

    Note: FairPlay Streaming will only provide protection for the video portion of your content. To prevent capture of the audio portion you should still use the UIScreen APIs discussed in this document to provide an appropriate message to the user if screen capture begins.

    One can get an in-depth understanding of FPS from the link below :

    https://developer.apple.com/streaming/fps/

    Any application can incorporate FPS in order to achieve same results as Netflix.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-09 03:07

    Netflix solution is NOT about the code. It is called DRM or Digital Rights Management. It protects the data from any piracy. Including screen records/shots and downloading. Man, it's expensive.

    0 讨论(0)
提交回复
热议问题