Skip to main content

DRM Playback

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

Play protected content

Playing protected content requires configuring license fetching for the AVURLAsset in context before loading or playing content. The player then uses the fetched license key for playback.

The LicenseFetcher is responsible for processing license fetch for all assets and delegates the task of fetching a license for each asset to its associated LicenseFetcherDelegate instance. The license fetcher delegate requires an application certificate, license URL, and SKD to fetch a streaming or persistent key for an asset.

A default implementation of LicenseFetcherDelegate is available with the FLPlayer library. If required, you can write your own implementation of fetching a license key by conforming to the LicenseFetcherDelegate protocol.

Update the AVURLAsset instance and its corresponding LicenseFetcherDelegate instance 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: The asset updated with the license fetcher must be the same asset used for playback with the player. Clean up the license delegate on playback completion to avoid license expiry errors because the license URL is valid only for a short time period.

Prefetch license

Your application must manage the list of assets for which keys are prefetched within a given session. This is a known platform limitation because there are no APIs to validate if a key is available with an AVContentKeySession instance. Additionally, attempting to fetch a key a second time results in no callbacks.

// Prefetch 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 later.

Warning: Use the prefetch API with caution because there are only limited slots available for key decryption on iOS device hardware.

We recommend creating one instance of LicenseFetcher and using it for the entire application session. You can set up and configure the LicenseFetcher to serve more than one player instance.