Setup the Bitmovin Player with DRMtoday

If you are not sure what DRM is, you want have an overview and get started, please have a look at our DRM Setup Guide.

Nearly every license provider, such as Irdeto or EZDRM, requires a few special information being sent to the DRM license server, or responds with a proprietary format. Instead of integrating a few license providers into the core of our player, we decided to provide necessary configuration options via the player configuration.

Widevine

var conf = {
  ...
  source: {
    ...
    drm: {
      widevine: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        headers : [{
          name: 'dt-custom-data',
          value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
        }],
        prepareLicense : function(licenseObj) {
          var license = {license: licenseObj.license};
 
          try {
            var drmTodayObj = JSON.parse(String.fromCharCode.apply(null, licenseObj.license));
            if (drmTodayObj && drmTodayObj.status && drmTodayObj.license) {
              if (drmTodayObj.status === 'OK') {
                var str = window.atob(drmTodayObj.license);
                var bufView = new Uint8Array(new ArrayBuffer(str.length));
                for (var i = 0; i < str.length; i++) {
                  bufView[i] = str.charCodeAt(i);
                }
                license.license = bufView;
              } else {
                // license not okay
              }
            } else {
              // no valid DRMtoday license
            }
          } catch (e) {
            // no valid DRMtoday license
          }
          return license;
        };
      }
    }
  }
}

PlayReady

var conf = {
  ...
  source: {
    ...
    drm: {
      playready: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        headers : [{
          name: 'http-header-CustomData',
          value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
        }]
      }
    }
  }
}

FairPlay

var conf = {
  ...
  source: {
    ...
    drm: {
      fairplay: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        certificateURL: 'https://certificate-url-provided-by-drmtoday',
        headers: [{
          name: 'dt-custom-data',
          value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
        }],
        prepareMessage : function(event, session) {
          return 'spc=' + encodeURIComponent(event.messageBase64Encoded) + '&' + session.contentId;
        },
        prepareContentId : function(contentId) {
          var pattern='skd://drmtoday?';
          var idx = contentId.indexOf(pattern);
          if (idx > -1) {
            var parameters = contentId.substring(idx + pattern.length);
            parameters = parameters.replace(/assetid/gi, 'assetId');
            parameters = parameters.replace(/variantid/gi, 'variantId');
            return parameters;
          } else {
            return '';
          }
        }
      }
    }
  }
}

Adobe Access (Flash Fallback)

var conf = {
  ...
  source: {
    ...
    drm: {
      access: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        authToken: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
      }
    }
  }
}

Complete example for Widevine, PlayReady, Access and FairPlay

var conf = {
  ...
  source: {
    ...
    drm: {
      widevine: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        headers : [{
          name: 'dt-custom-data',
          value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
        }],
        prepareLicense : function(licenseObj) {
          var license = {license: licenseObj.license};
 
          try {
            var drmTodayObj = JSON.parse(String.fromCharCode.apply(null, licenseObj.license));
            if (drmTodayObj && drmTodayObj.status && drmTodayObj.license) {
              if (drmTodayObj.status === 'OK') {
                var str = window.atob(drmTodayObj.license);
                var bufView = new Uint8Array(new ArrayBuffer(str.length));
                for (var i = 0; i < str.length; i++) {
                  bufView[i] = str.charCodeAt(i);
                }
                license.license = bufView;
              } else {
                // license not okay
              }
            } else {
              // no valid DRMtoday license
            }
          } catch (e) {
            // no valid DRMtoday license
          }
          return license;
        };
      },
      playready: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        headers : [{
          name: 'http-header-CustomData',
          value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
        }]
      },
      fairplay: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        certificateURL: 'https://certificate-url-provided-by-drmtoday',
        headers: [{
          name: 'dt-custom-data',
          value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
        }],
        prepareMessage : function(event, session) {
          return 'spc=' + encodeURIComponent(event.messageBase64Encoded) + '&' + session.contentId;
        },
        prepareContentId : function(contentId) {
          var pattern='skd://drmtoday?';
          var idx = contentId.indexOf(pattern);
          if (idx > -1) {
            var parameters = contentId.substring(idx + pattern.length);
            parameters = parameters.replace(/assetid/gi, 'assetId');
            parameters = parameters.replace(/variantid/gi, 'variantId');
            return parameters;
          } else {
            return '';
          }
        }
      },
      access: {
        LA_URL: 'https://license-server-url-provided-by-drmtoday',
        authToken: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
      }
    }
  }
}
Back to Top
Simple Share Buttons