3

We are implementing fairplay with our videoplayer and we are able to do all the steps apple requires to play drm videos, but the video just doesn't play. We are able to:

  1. Receive a call on our delegate: shouldWaitForLoadingOfRequestedResource
  2. On the above call, we download the certificate properly, and with the certificate + assetId, we successufuly generate the SPC
  3. With the SPC, we are able to POST to license server and sucesfully receive the CKC
  4. With the CKC, we call

    loadingRequest.dataRequest?.respond(with: ckcResponseData)  
    loadingRequest.finishLoading()
    

But the video just doesn't start playing. Is there anything we are missing? Do we need the "FPS Deployment Package" in order to make it work with our apple account? Notice we are testing on real devices already.

Daniel Ramos
  • 251
  • 1
  • 6
  • i would need your help on fairplay video playback for drm video files. I dont have any idea wr to start. I downloaded the apple doc with sample project of `HLSCatalogWithFPS - AVAssetResourceLoader`. but not able to get exact steps to follow. Could you please help me on that. – david May 18 '19 at 04:09

1 Answers1

0

It's hard to say without seeing your implementation. Anyway here's what I can share based on my experience with FairPlay. I assume your play CAN play non encrypted videos, so it's well implemented and working.

If you get successfully to the "finishLoading" piece, on the other side (and before all of that happen), you need to register as observer for "currentItem.status" on the player. Something like:

player.addObserver(self, forKeyPath: "currentItem.status", options: NSKeyValueObservingOptions.new, context: nil);

So, at some stage, you will get observeValueForKeyPath callback, and you will need to check what's going on:

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    // Do any other KVO-related checks... and the following:
    if let status = self.player.currentItem?.status {
        switch (status) {
        case .failed:
            // Something went wrong!
            self.itemFailed()
        case .readyToPlay:
            // Item is ready to play, so just .play() it!
            self.itemReadyToPlay()
        case .unknown:
            // Oh-oh.
            self.itemUnknown()
        }
    }
}

Let me know if you are already at this stage, what errors do you get.

(what's shared here it's not specific about FairPlay, but it's more general about loading assets, it doesn't break any License Agreement)

Andre
  • 1,135
  • 9
  • 20