Skip to main content
Skip table of contents

Callback mode

To test this feature and view the example code, please see the  Browsers SDK 1 Example Code Quick Start guide.

To define custom actions during DRM licence acquisition, you can initialise the otvtoolkit in callback mode.

This is an alternative form of integrating DRM to providing details of the system with subsequent licenceServer and tenantId attributes. Here the SDK handles this all with a finite set of DRM systems and modes of operation, which allows much greater flexibility.

Configuration

Indicate the system as "customer" and provide configuration of requestLicenceCallback as a function that will be triggered when DRM licencing is acquired ahead of playback.

JS
plugins: {
    otvtoolkit: {
        drm: {
            system: "customer",
            config: {
                requestLicenceCallback: myLicenceRetrievalFunction
            }
        }
    }
}

Adaption for FPS

A small variation from the above is required for FairPlay in the Safari browser. Here the drm.config needs provision of the FairPlay certificate.

JS
ins: {
    otvtoolkit: {
        drm: {
            system: "customer",
            config: {
                fairplayServerCertificate: certificate,
                requestLicenceCallback: myLicenceRetrievalFunction
            }
        }
    }
}

Requirements of your implementation

The requestLicenceCallback function defined must:

  • Accept arguments where the following can be provided:
    • Key system
    • An object with details of the asset to be played back
    • The payload of the request message
    • Message type (e.g. license-request or licence-renewal)
  • Return a Promise which will resolve on the completion of the delivery of the message.

See below for the basic outline of how your requestLicenceCallback function should look.

JS
function myLicenceRetrievalFunction(keySystem, source, requestPayload, messageType) {
   var url;
   var headers;
 
   if (messageType === "license-renewal") {
       ...
   } else {
       ...
   }
 
   if (keySystem === "com.widevine.alpha") {
       ...
   } else if (keySystem === "com.microsoft.playready") {
       ...
   } else {
       ...
   }
   return new Promise(function resolver(resolve, reject) {
       ...
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.