Reputation: 735
Implemented the delegate methods of AVContentKeySessionDelegate within my ViewController.swift in my iOS application which is to play drm content using Brightcove SDK.
class ViewController: UIViewController, AVContentKeySessionDelegate, BCOVPlaybackControllerDelegate {
var contentKeySession: AVContentKeySession!
.
.
func getVideo() {
// fetching video using an API call
.
.
let asset = AVURLAsset(url: videoUrl)
self.contentKeySession = AVContentKeySession(keySystem: .fairPlayStreaming)
self.contentKeySession?.setDelegate(self, queue: DispatchQueue.main)
self.contentKeySession?.addContentKeyRecipient(asset)
}
//MARK: - AVContentKeySessionDelegate Methods
func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest) {
handleKeyRequest(keyRequest: keyRequest)
}
func contentKeySession(_ session: AVContentKeySession, contentKeyRequest keyRequest: AVContentKeyRequest, didFailWithError err: Error) {
print(err)
}
func contentKeySession(_ session: AVContentKeySession, contentKeyRequestDidSucceed keyRequest: AVContentKeyRequest) {
print(keyRequest)
}
}
Upvotes: 0
Views: 1067
Reputation: 39
I believe that the intent of self.contentKeySession.processContentKeyRequest
is to cache the content key. In theory, the content session key delegate should be called as long as the content is protected.
Upvotes: 2
Reputation: 735
Adding
self.contentKeySession.processContentKeyRequest(withIdentifier: "<identifier>", initializationData: nil, options: nil)
fixed the issue. When the request to process content key is made, the delegate methods are getting invoked.
Upvotes: 1