Enabling playback of FPS encrypted content using OTVSSPLicenseDelegate
To enable FairPlay Streaming in your app using the OTVSSPLicenseDelegate
:
Create a new Xcode project and then instantiate the
OTVSSPLicenseDelegate
. This delegate needs to authenticate both the stream, the licence server and optionally the SSM server if you are using SSP Secure Session Management.
The code below shows how you would instantiate theOTVSSPLicenseDelegate
without SSM.APPLESCRIPTlet licenseDelegate: OTVSSPLicenseDelegate? licenseDelegate = OTVSSPLicenseDelegate(certificateURL: sspCertificateURL, licenseURL: licenseURL)
Instantiate an
OTVDRMManager
object inOPYFPSSDK
to negotiate betweenOTVAVPlayer
and your app (via theOTVSSPLicenseDelegate
implementation).APPLESCRIPTprivate let drmManager = OTVDRMManager:shared
Register the delegate to the
OTVDRMManager
:APPLESCRIPTdrmManager.setLicenseDelegate(licenseDelegate)
To enable the delegate to request a licence successfully, you need to set a media token. There are two options to do this:
setStream()
andsetToken()
. If your token is static for the playback session, usesetStream()
; however, if you need to update the media token for any subsequent licence request, usesetToken()
.setStream()
is the simplest way to set the token for the licence request. Use this method if you only intend to use one licence for the associated playback.
For example, if Airplay is enabled, another licence request will take place and will use the original token (one passed intosetStream()
) to make that licence request.APPLESCRIPTlicenseDelegate.setStream(token: sspToken, with: assetURL)
setToken()
triggers a callback whenever a subsequent licence request takes place for the associated playback item. One example is when enabling Airplay; it triggers a licence request and if you need a new media token for this licence request, using this callback is the only way this is possible.CODElicenseDelegate?.setToken(initialToken: sspToken, tokenCallback: { () -> String in return self.sspToken })
Instantiate an
OTVAVPlayer
using either the content URL or anOTVAVPlayerItem
object and call itsinit()
method:APPLESCRIPTprivate let player = OTVAVPlayer() player(item) /// or: private let player = OTVAVPlayer() player(url)
You should now be able to use the
OTVAVPlayer
object to playback FPS-encrypted content in the same way as withAVPlayer
.