Retrieving the licence
Set up your application to request licenses from the license server in a similar way as for encrypted streaming.
- If the content identifier is known to the application, the application may request the license before instigating the download; this is sometimes called the prefetch stage. When requesting a license for a persistent asset, the App must request the license from the
OTVDRMManager
with the license optionOTVLicenseOptionOffline
set to true. An instance ofOTVLicenseDelegate
needs to be set ondrmmanager
before prefetching the license. Make sure this prefetch method is used only for a single download at a time.To prefetch licenses for multiple downloads, use the following to ensure that there are separate delegates associated with each download:
CODEOTVPersistenceManager.shared.startDownload(urlAsset: urlAsset, title: assetName, licenseDelegate: delegate, artwork: nil, options: option) { }
- If the content identifier is not known and is embedded within the EXT-X-KEY or EXT-X-SESSION-KEY tag of the HLS playlists, the
OTVPersistenceManager
handles requesting the license on behalf of the application.
In both cases, OTVPersistenceManager
fetches the license and persists it for the lifetime of the OTVPersistenceAsset
it creates.
Example code
if let contentId = stream.contentId, !contentId.isEmpty {
let options = [OTVDRMManager.Keys.OTVLicenseOptionOffline: true as Any]
OTVDRMManager.shared.requestLicense(identifier: contentId, license: options)
}
Next step: For encrypted content, you can now start the download