Skip to main content

Entitlement and DRM

What you learn​

You're instantiating DIVA Player in your web front-end and relying on DIVA Back Office as the video streaming source.

The goal of this article is to build the simplest front-end to stream a video from the DIVA Back Office with entitlement check and DRM.

Before starting​

  • Set up the development environment.
  • Ensure the DIVA Back Office instance you rely on is up and running.
  • Ask your video engineers team the <video id> and <settings URL>.
  • Ensure the settings file contains:
    • The entitlementCheck section:
      "entitlementCheck": {
      "entitlementUrl": "<yourEntitlementBaseURL>/tokenize",
      "heartbeatUrl": "<yourEntitlementBaseURL>/heartbeat",
      "heartbeatPollingInterval": 180000,
      "other": "{<sessionId>}|{<platform>}",
      "fairPlayCertificateUrl": "<yourFairPlayCertificateBaseURL>/fairplay.cer"
      }
    • The videoPlatformsPriority section:
      "videoPlatformsPriority": {
      "default": [
      {
      "type": "DASH",
      "sourceName": "Desktop-DASH",
      "drmType": "playready"
      },
      {
      "type": "DASH",
      "sourceName": "Desktop-DASH",
      "drmType": "widevine"
      },
      {
      "type": "HLS",
      "sourceName": "Desktop-V4",
      "drmType": "fairplay"
      }
      ],
      "chromecast": [
      {
      "type": "DASH",
      "sourceName": "Chromecast-DASH",
      "drmType": "widevine"
      }
      ]
    }

Instantiation​

DRM code​

There's no code to add to the Basic instantiation code.

Entitlement code​

Enrich the Basic instantiation code with the entitlement configuration:

  • entitlementUser: It returns the token that entitles a video player user to stream a specific video.
  • entitlementPlatform: Platform parameter used to request the entitlement token.

Entitlement code sample​

Write the entitlement configuration:

const token = "<entitlement token of the video player user>";

const entitlementConfiguration = {
entitlementUser: () => token,
entitlementPlatform: "<platform>"
};

Finally, add the entitlementConfiguration to the DIVA Player instantiation:

<DivaWebBoAdapter
settingsURL={"<settingsURL>"}
languageCode={"en-US"}
config={config}
entitlementConfiguration={entitlementConfiguration}
/>

Working sample code (.tsx)​

import React from "react";
import { DivaWebBoAdapter } from "@deltatre-vxp/diva-sdk/diva-web-bo-adapter";
import "@deltatre-vxp/diva-sdk/diva-web-sdk/index.min.css";

const videoId = "<videoId";

const libs = {
mux: "https://cdnjs.cloudflare.com/ajax/libs/mux.js/6.2.0/mux.min.js",
shaka: "https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.7.11/shaka-player.compiled.js",
hlsJs: "https://cdn.jsdelivr.net/npm/hls.js@1.4.12",
googleIMA: false,
googleDAI: false,
googleCast: false,
threeJs: false
};

const config = {
videoId: videoId,
libs: libs,
};

const token = "<entitlement token of the video player user>";

const entitlementConfiguration = {
entitlementUser: () => token,
entitlementPlatform: "<platform>"
};

const props = {
settingsUrl: "<Settings URL>",
languageCode: "en-US",
languageDictionary: "en-US",
onDivaBoAdapterError: console.error,
config: config,
entitlementConfiguration: entitlementConfiguration
}

function App() {
return (
<DivaWebBoAdapter
{
...props
}
/>
);
}

export default App;