2

WideVine iOS CDM Player is playing DRM Protected content. Now, iOS11 introduce a new built-in feature i.e Screen Recording. Using this feature a user can easily capture or record DRM Protected content.

I used iOS11 Beta isCaptured and UIScreenCapturedDidChange Property and try to prevent DRM protected content to recorded, But This isCaptured and UIScreenCapturedDidChange working fine when the first time I Launch my Application. Now, when I Kill my running App(Terminate the application) and Launch again then my App doesn't receive any value for isCaptured and UIScreenCapturedDidChange.

Now I try to record Netflix and Amazon Prime content using iOS11 screen recording feature but it will don't allow to record and gives a Black screen.

I want similar Black screen when screen recording is On in iOS11 device, But I don't have the solution. If anyone has then please help.

UmeshKumath
  • 121
  • 1
  • 6

3 Answers3

3

Netflix and Amazon prime iOS apps are using Apple DRM solution for apple devices - FairPlay (https://developer.apple.com/streaming/fps/). When AVPlayer plays FairPlay encrypted content it can't be captured by Screen Recording in iOS11.

shpasta
  • 1,913
  • 15
  • 21
2

You can use UIScreen.main.isCaptured to tell if the screen is being recording by screen recording or AirPlay etc...then show your black view to cover your screen

Tj3n
  • 9,837
  • 2
  • 24
  • 35
  • Thank You, But when I try to capture UIScreen.main.isCaptured events using KVO then the first time it notifies the selector method with value True, but when I kill (terminate) my running App and Launch app again and do the same procedure again then my selector method is not getting called. – UmeshKumath Sep 22 '17 at 11:41
  • 1
    Register for the NSNotification instead of KVO `UIScreenCapturedDidChangeNotification` -- see more here https://stackoverflow.com/a/46370265/2145198 – beebcon Oct 25 '17 at 16:37
0

You just need to make the following changes in your Appdelegate.swift page.

It will automatically add a blurred view on the top of the app when the user tries to record the screen.

    weak var screen : UIView? = nil

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    NotificationCenter.default.addObserver(self, selector: #selector(preventScreenRecording), name: UIScreen.capturedDidChangeNotification, object: nil)
    return true
}

@objc func preventScreenRecording() {
    let isCaptured = UIScreen.main.isCaptured
    print("isCaptured: \(isCaptured)")
    if isCaptured {
        blurScreen()
    }
    else {
        removeBlurScreen()
    }
}

func blurScreen(style: UIBlurEffect.Style = UIBlurEffect.Style.regular) {
    screen = UIScreen.main.snapshotView(afterScreenUpdates: false)
    let blurEffect = UIBlurEffect(style: style)
    let blurBackground = UIVisualEffectView(effect: blurEffect)
    screen?.addSubview(blurBackground)
    blurBackground.frame = (screen?.frame)!
    window?.addSubview(screen!)
}

func removeBlurScreen() {
    screen?.removeFromSuperview()
}
midhun p
  • 1,987
  • 18
  • 24