Skip to main content

DRM Playback

Quickplay Player is pre-integrated with common multi-DRM solutions.

Playing Protected Content

Playing a protected content requires configuring license fetching for the AVURLAsset in context prior to loading or playing content, so that the Player makes use of the fetched license key for playback.

The LicenseFetcher, which is responsible for processing license fetch for all assets, delegates the task of fetching license for each asset to its tied up instance of LicenseFetcherDelegate. The license fetcher delegate would require application certificate, license url and skd to fetch a streaming or persistent key for an asset.

A default implementation of LicenseFetcherDelegate is available with FLPlayer library. If required one can write their own implementation of fetching license key conforming to LicenseFetcherDelegate protocol.

The AVURLAsset instance and its corresponding LicenseFetcherDelegate instance must be updated with the LicenseFetcher.

// Create License Fetcher
let lf: FairplayLicenseFetcher? = FLPlayerFactory.fairplaylicenseFetcher()

// Create License Fetcher Delegate
let delegate = FLPlayerFactory.fairplayLicenseFetcherDelegate(
applicationCertificate: appCert,
licenseUrl: licenseURL,
skd: skd,
keyDeliveryType: .streamingKey)

// Update License Fetcher to process key fetching for an AVURLAsset
if let avURLAsset = player.avURLAsset {
lf.updateLicenseFetcherDelegate(delegate, for: avURLAsset)
}
note

Please note the asset updated with the license fetcher must be the same asset used for playback with the Player. It is suggested to clean up the license delegate on playback completion to avoid license expiry errors as the license url would be valid only for a short time period.

Prefetching License

Application must own managing the list of asset for which keys are pre-fetched within a given session. This is a known platform limitation, as there are no APIs to validate if a key is available with a AVContentKeySession instance or not. Also, attempting to fetch a key second time results in no callbacks.

// pre-fetching key
lf.fetchFairplayLicense(for: skd) { (result: Result<Void, Error>) in
switch result {
case .success:
// handle success
case let .failure(error):
// handle error
}
}
note

Available on iOS 10.3 and above.

caution

Use the pre-fetch API with caution as there are only limited slots available for key decryption on iOS device hardware.

We recommend creating one instance of LicenseFetcher and use the same for entire application session. The LicenseFetcher can be set up and configured to serve more than one player instance.