Callback Mode
The React Native Player handles license management internally within the code to support multi-DRM through SSP. In certain setups, you might want to manage content licenses through your own mechanisms to generate a license and share it with the React Native player to play an encrypted content item. You can achieve this by creating your implementation for license fetching in the form of a JS promise and providing it to the CONNECT Player SDK.
Callback mode is currently only available for Web Browsers and browser-based platforms such as Connected TVs.
Example code
The following describes how to prepare your own implementation of a callback promise and provide it to the player. Four examples are provided - one for each DRM system, essentially having the same functionality. Their names are self-explanatory:
- CallbackModeFairPlay.tsx
- CallbackModePlayReady.tsx
- CallbackModeTVKey.tsx
- CallbackModeWidevine.tsx
These examples provide the typical implementation of callback mode for an SSP licence server.
The React Native player provides a callback property: onLicenseRequest(keySystem:String, source:Object, requestPayload:ArrayBurrer, licenseRequestType:String) . If the application sets this, it will be called whenever the player wants the application to provide any of the following:
- License data
- Certificate data
- Renewed license data
The App should return a promise from this callback. Once the promise is fulfilled, the data provided should be an ArrayBuffer of the reply from the license server.
- If the promise is rejected, playback will fail and an
onErrorevent will be triggered. - The player will discard the last promise if a channel/content change is requested before fulfilling or rejecting a promise.
Apps should make sure not to accept/reject promises made for the previous content (if a new request was made).
Please refer to the API documentation regarding the parameters passed in the callback.
Using the CallbackModeWidevine example as a reference, define and implement the licence-fetching promise, returned by the getWidevineLicense() method of type OnLicenseRequest :
The promise returned by this method will return a byte array (Uint8Array) of the response from the SSP license server if successful ( resolve ), or an error string if the request failed ( reject ). The getWidevineLicense function is then passed as the onLicenseRequest callback prop during the OTVPlayer object's construction.
Mixed mode
To change between callback and non-callback mode, the App has to unmount and remount OTVPlayer.
- If OTVPlayer is mounted with the property
onLicenseRequest(callback mode), to ignore the license request, OTVPlayer has to be unmounted and remounted with noonLicenseRequest(non-callback mode). - Alternatively, if OTVPlayer is mounted with no
onLicenseRequest(non-callback mode), to handle the license request, OTVPlayer has to be unmounted and remounted withonLicenseRequest(callback mode).
If OTVPlayer is not unmounted while changing between callback and non-callback mode, the error 7025 will be thrown indicating mixed mode error.