Skip to main content

Cloud DRM

Overview

Bradmax player supports integration with Cloud DRM for protected content playback. This guide demonstrates how to configure the player to work with Cloud DRM license acquisition endpoints for Widevine, PlayReady, and FairPlay DRM systems.

The player requires the license acquisition URLs and Cloud DRM token for license acquisition. See Cloud DRM documentation for more details. Your Cloud DRM license acquisition URLs can be found in the Cloud Video Kit web console under DRM → Configuration → License acquisition.

Configuration

For correct playback, the player needs:

  • Cloud DRM token for license acquisition.
  • PlayReady license server URL.
  • Widevine license server URL.
  • FairPlay license server URL.
  • FairPlay license server certificate URL.
  • DRM-protected MPEG-DASH manifest URL.
  • DRM-protected HLS manifest URL.

Example

function appendTokenToUrl(url, token) {
const urlObject = new URL(url);
urlObject.searchParams.set("usertoken", token);

return urlObject.toString();
}

const USER_TOKEN = "CLOUD-DRM-TOKEN";

const fairplayDrmConfigUrl = appendTokenToUrl(
"<YOUR-FAIRPLAY-LICENSE-ACQUISITION-URL>",
USER_TOKEN
);

const fairplayCertUrl = "<YOUR-FAIRPLAY-CERTIFICATE-URL>";

var playerConfig = {
dataProvider: {
skin: { theme: "disco" },
source: [
{
url: "<YOUR-PROTECTED-DASH-URL>",
drm: {
provider: "default",
playready: {
laUrl: appendTokenToUrl(
"<YOUR-PLAYREADY-LICENSE-ACQUISITION-URL>",
USER_TOKEN
),
},
widevine: {
laUrl: appendTokenToUrl(
"<YOUR-WIDEVINE-LICENSE-ACQUISITION-URL>",
USER_TOKEN
),
},
},
},
{
url: "<YOUR-PROTECTED-HLS-URL>",
drm: { provider: "viaEvent" },
},
],
},
};

function onFairplayDrmNeeded(event) {
const keyMessage = event.data.keyMessage;
const keySession = event.data.keySession;
const params = new URLSearchParams(
event.data.keySession.keyPath.split("?")[1]
);
const licenseServerUrl = new URL(fairplayDrmConfigUrl);
params.forEach((value, key) => {
licenseServerUrl.searchParams.set(key, value);
});

var licReq = new XMLHttpRequest();
licReq.open("POST", licenseServerUrl.toString(), true);
licReq.responseType = "arraybuffer";
licReq.onload = function () {
if (licReq.status === 200) {
const license = licReq.response;
jsapi.drm.provideFairplayLicense(keyMessage, license);
} else {
const errorMessage = licReq.response;
jsapi.drm.provideFairplayLicense(keyMessage, null, errorMessage);
}
};
licReq.onerror = licReq.onload;
licReq.send(keyMessage);
}

function onFairplayCertNeeded(event) {
var certReq = new XMLHttpRequest();
certReq.open("GET", fairplayCertUrl, true);
certReq.responseType = "arraybuffer";
certReq.onload = function () {
if (certReq.status === 200) {
const cert = certReq.response;
jsapi.drm.provideFairplayCertificate(cert);
} else {
const errorMessage = licReq.response;
jsapi.drm.provideFairplayLicense(null, errorMessage);
}
};
certReq.onerror = certReq.onload;
certReq.send();
}

var element = document.getElementById("player");
var player = window.bradmax.player.create(element, playerConfig);
var jsapi = player.modules.JavascriptApi;

jsapi.add(
"DrmLicenseProviderEvent.extRequestFairplayCertificate",
onFairplayCertNeeded
);

jsapi.add(
"DrmLicenseProviderEvent.extRequestFairplayLicense",
onFairplayDrmNeeded
);

For more detailed information about integrating Bradmax Player with Cloud DRM, visit the Cloud Video Kit documentation.