Offline playback of PRM encrypted content
Offline playback of PRM content works similarly to that of FPS or clear content. To download PRM content, make the following additional changes.
The PRM license must be requested by calling the following API at any time before offline playback is attempted:
let options = [String: Any]() // include any parameters required to specify the content that the license is being requested for
OTVPRMManager.shared().requestPersistentLicense(options)
As with playback of PRM content, an OTVPRMAVURLAsset
must be passed to OTVPersistenceManager
to download,
let urlAsset = OTVPRMAVURLAsset(url: url)
let persistenceAsset = OTVPersistenceManager.sharedManager.startDownload(urlAsset: urlAsset, title: assetName, artwork: nil, options: options)
When the download is complete, playback can be achieved with the following code:
let offlineURL = persistenceAsset.offlineURL()
let prmAsset = OTVPRMAVURLAsset(url: offlineURL)
let item = OTVAVPlayerItem(asset: prmAsset)
let player = OTVAVPlayer(playerItem: item)
player.play()