Documentation

Radiant Media Player

Working with DRMtoday by castLabs

Scope of support

DRMtoday by castLabs is a popular DRM service provider. Radiant Media Player is compatible with DRMtoday technology to reliably deliver content with DASH in both Widevine and PlayReady DRM and with HLS in FairPlay DRM. You can review our compatibility table for DRM with DASH or HLS streaming here.

This documentation will guide you on how to easily implement DRMtoday with Radiant Media Player.

DASH with Widevine and PlayReady DRM

First, you will need an account with DRMtoday by castLabs and to prepare your content for DASH streaming with Widevine and PlayReady DRM. Radiant Media Player will take care of loading and parsing the DASH manifest, contacting the DRM licensing servers and displaying content when authorised. Our DASH streaming & DRM implementation is based on Shaka player. Documentation for DASH streaming with Radiant Media Player can be found here. Documentation for using DRM with Radiant Media Player can be found here. Below you will find a complete example for using DRMtoday with Radiant Media Player.

<script src="https://cdn.radiantmediatechs.com/rmp/6.2.3/js/rmp.min.js"></script>
<div id="rmpPlayer"></div>
<script>
  // DASH streaming URL
  var src = {
    dash: 'https://your-dash-url.mpd'
  };
  // license server for PlayReady
  var playReadyLaURL = 'https://aaa.bbb.drmtoday.com/license-proxy-headerauth/drmtoday/RightsManager.asmx';
  // license server for Widevine
  var widevineLaURL = 'https://aaa.bbb.drmtoday.com/license-proxy-widevine/cenc/';

  // create Radiant Media Player instance
  var elementID = 'rmpPlayer';
  var rmp = new RadiantMP(elementID);

  // custom request DRM filter for Radiant Media Player to properly access DRMtoday licensing servers
  var shakaCustomRequestFilter = function (type, request) {
    if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
      request.headers['dt-custom-data'] = btoa(JSON.stringify({
        userId: 'your-user-id',
        sessionId: 'your-sesson-id',
        merchant: 'your-merchant-id'
      }));
    }
  };
  // custom response DRM filter for Radiant Media Player to properly access DRMtoday licensing servers
  var shakaCustomResponseFilter = function (type, response) {
    if (type !== shaka.net.NetworkingEngine.RequestType.LICENSE) {
      return;
    }
    var responseText = shaka.util.StringUtils.fromUTF8(response.data);
    if (responseText.indexOf('<AcquireLicenseResponse') > -1) {
      // If playready do nothing
    } else {
      try {
        // If widevine response
        var wrapped = JSON.parse(responseText);
        response.data = shaka.util.Uint8ArrayUtils.fromBase64(wrapped.license);
      } catch (e) {
        window.console.log(e);
      }
    }
  };
  var settings = {
    licenseKey: 'your-license-key',
    src: src,
    width: 640,
    height: 360,
    contentMetadata: {
      poster: [
        'https://your-poster-url.jpg'
      ]
    },
    // here we pass our custom DRM data
    shakaDrm: {
      servers: {
        "com.widevine.alpha": widevineLaURL,
        "com.microsoft.playready": playReadyLaURL
      }
    },
    shakaCustomRequestFilter: shakaCustomRequestFilter,
    shakaCustomResponseFilter: shakaCustomResponseFilter
  };
  rmp.init(settings);
</script>

Apple FairPlay streaming (FPS)

We also support FairPlay streaming with DRMtoday by castLabs to Radiant Media Player. FairPlay streaming, which requires HLS, aims at providing support for DRM encrypted content to Apple devices, for us this is macOS Safari 10+, Safari for iOS 12+, iPadOS 13+ and iOS 13+ WebView. More information about FPS support in Radiant Media Player can be found here.

<script src="https://cdn.radiantmediatechs.com/rmp/6.2.3/js/rmp.min.js"></script>
<div id="rmpPlayer"></div>
<script>
  // HLS FPS streaming URL
  var src = {
    fps: 'https://fps-hls-url.m3u8'
  };
  // FPS certificate URL
  var certificatePath = 'https://aaa.bbb.drmtoday.com/license-server-fairplay/cert/ccc';
  // FPS license server URL
  var processSpcPath = 'https://aaa.bbb.drmtoday.com/license-server-fairplay/';
  // HTTP headers for FPS license server URL
  var licenseRequestHeaders = [
    {
      name: 'dt-custom-data',
      value: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
    }
  ];
  // Prepare body for license request
  var licenseRequestMessage = function (message) {
    return message;
  };
  // Prepare contentId
  var extractContentId = function (initData) {
    var arrayToString = function (array) {
      var uint16array = new Uint16Array(array.buffer);
      return String.fromCharCode.apply(null, uint16array);
    };
    var contentId = arrayToString(initData);
    var pattern = 'skd://';
    var parameters;
    var idx = contentId.indexOf(pattern);
    if (idx > -1) {
      parameters = contentId.substring(idx + pattern.length);
      parameters = parameters.replace(/assetid/gi, 'assetId');
      parameters = parameters.replace(/variantid/gi, 'variantId');
      return parameters;
    } else {
      return '';
    }
  };
  // Player settings
  var settings = {
    licenseKey: 'your-license-key',
    src: src,
    width: 640,
    height: 360,
    fpsDrm: {
      certificatePath: certificatePath,
      processSpcPath: processSpcPath,
      licenseRequestHeaders: licenseRequestHeaders,
      licenseRequestMessage: licenseRequestMessage,
      extractContentId: extractContentId
    }
  };
  var elementID = 'rmpPlayer';
  var rmp = new RadiantMP(elementID);
  rmp.init(settings);
</script>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.

©2015-2021 Radiant Media Player. All rights reserved.