Skip to main content

Cloud DRM

This article describes how to configure Cloud DRM with the Dolby OptiView player (formerly THEOplayer).

For general information about DRM, see our DRM introduction.

SDKs

Web SDKAndroid SDKiOS SDKtvOS SDKAndroid TV SDKChromecast SDK
YesYesYesYesYesYes

Code Examples

Web SDK (Dolby OptiView / THEOplayer)

HTML/JavaScript example:
<script>
var element = document.querySelector(".theoplayer-container");
var player = new THEOplayer.Player(element, {
libraryLocation: "SDK-LIBRARY-LOCATION",
license: "YOUR-LICENSE-STRING",
});

const drmConfiguration = {
integration: "clouddrm",
integrationParameters: {
token: "CLOUD-DRM-TOKEN",
},
preferredKeySystems: ["playready", "widevine", "fairplay"],
// copy license acquisition URL and certificate URL from DRM console settings page: https://console.videokit.cloud/dashboard/drm/configuration
playready: {
licenseAcquisitionURL: "<YOUR-PLAYREADY-LICENSE-ACQUISITION-URL>",
},
widevine: {
licenseAcquisitionURL: "<YOUR-WIDEVINE-LICENSE-ACQUISITION-URL>",
},
fairplay: {
licenseAcquisitionURL: "<YOUR-FAIRPLAY-LICENSE-ACQUISITION-URL>",
certificateURL: "<YOUR-FAIRPLAY-CERTIFICATE-URL>",
},
};

player.source = {
sources: [
{
src: "https://<YOUR-PROTECTED-DASH-URL>/dash/index.mpd",
type: "application/dash+xml",
contentProtection: drmConfiguration,
},
{
src: "https://<YOUR-PROTECTED-HLS-URL>/hls/index.m3u8",
type: "application/x-mpegURL",
contentProtection: drmConfiguration,
},
],
};
</script>

Replace the following placeholders:

Android/iOS/tvOS SDKs

For native SDK integration, refer to the official Dolby OptiView documentation and use the Cloud DRM integration module. The configuration is similar: provide the DRM token and license/certificate URLs as required by the platform SDK.

See the DRM introduction for platform-specific examples.

Obtaining Cloud DRM token

This section demonstrates how to generate a JWT for obtaining DRM licenses from the Cloud DRM service.
First, log in to your Cloud DRM dashboard.
Go to DRMConfigurationLicense acquisition and copy the Signing Key. Use this signing key to create JWT tokens on your backend.

To generate a signed JWT, you can use the following Python script with the PyJWT package. In the example below, only the required token claims are included. For testing purposes, the token's validity is set until the year 2027. However, in a typical scenario, the token should be generated by the backend just before playback begins, and the "exp" (expiration) field should be set to NOW() + 10 minutes.

import jwt
import json
import base64

base64_signingkey = 'put signing key here'

payload = {
"exp": 1798758000, #put future timestamp here
"kid": ["*"],
"duration": 86400
}

binary_signingkey = base64.b64decode(base64_signingkey)
encoded_jwt = jwt.encode(payload, binary_signingkey, algorithm='HS256')
print(encoded_jwt)

The token will look like this:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE5MTc0OTgyNzgsImtpZCI6WyIqIl0sImR1cmF0aW9uIjo4NjQwMH0._zRj1xAdpNhQ0JEgCryvZ-4UkwHvQgwJjOkDBwQuK_A

If you need to specify extended license parameters, you can use the more detailed token payload example:

import jwt
import json
import base64

base64_signingkey = 'put signing key here'

payload = {
"exp": 1798758000,
"kid": ["*"],
"duration": 86400,
"widevine": {
"level": 1,
"hdcp": "HDCP_V2",
"license_duration": 3600
},
"playready": {
"level" : 3000,
"uncompressed_digital_video_opl" : 300,
},
"fairplay": {
"hdcp":true
}
}

binary_signingkey = base64.b64decode(base64_signingkey)
encoded_jwt = jwt.encode(payload, binary_signingkey, algorithm='HS256')
print(encoded_jwt)

The resulting token will look like this:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE5MTc0OTgyNzgsImtpZCI6WyIqIl0sImR1cmF0aW9uIjo4NjQwMCwid2lkZXZpbmUiOnsibGV2ZWwiOjEsImhkY3AiOiJIRENQX1YyIiwibGljZW5zZV9kdXJhdGlvbiI6MzYwMH0sInBsYXlyZWFkeSI6eyJsZXZlbCI6MzAwMCwidW5jb21wcmVzc2VkX2RpZ2l0YWxfdmlkZW9fb3BsIjozMDB9LCJmYWlycGxheSI6eyJoZGNwIjp0cnVlfX0.-YK8vULyooj6K3Fee4hffOl9uhZSq2y_4K9H5ac2Fjs

To learn more about authorization with Cloud DRM, please visit the Cloud Video Kit documentation for developers.

Resources