Playing protected content with Pollycon DRM - Web

Overview

Nearly every license provider requires a few special pieces of information to be 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

const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
      widevine: {
        LA_URL: 'POLLYCON_LICENSE_SERVER_URL',
        headers: {
          'pallycon-customdata-v2' : 'POLLYCON_LICENSE_TOKEN'
        },
        mediaKeySystemConfig: {
          persistentState: 'required',
        },
        serverCertificate: ''
      }
    }
  };

PlayReady

  const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
      playready: {
        LA_URL: 'POLLYCON_LICENSE_SERVER_URL',
        headers: {
          'pallycon-customdata-v2' : 'POLLYCON_LICENSE_TOKEN'
        }
      }
    }
  };

FairPlay

const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
      fairplay: {
        LA_URL: 'POLLYCON_LICENSE_SERVER_URL',
        headers: {
          'pallycon-customdata-v2' : 'POLLYCON_LICENSE_TOKEN'
        },
        certificateURL: 'CERTIFICATE_URL',
        prepareContentId: function (contentId) {
          return contentId.substring(contentId.indexOf('skd://') + 6);
        },
        prepareCertificate: function (rawResponse) {
          var responseText = String.fromCharCode.apply(null, new Uint8Array(rawResponse));
          var raw = window.atob(responseText);
          var rawLength = raw.length;
          var certificate = new Uint8Array(new ArrayBuffer(rawLength));

          for (var i = 0; i < rawLength; i++)
            certificate[i] = raw.charCodeAt(i);

          return certificate;
        },
        useUint16InitData: true
      }
    }
  };

Complete example for Widevine, PlayReady and FairPlay

 const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
      widevine: {
        LA_URL: 'POLLYCON_LICENSE_SERVER_URL',
        headers: {
          'pallycon-customdata-v2' : 'POLLYCON_LICENSE_TOKEN'
        },
        mediaKeySystemConfig: {
          persistentState: 'required',
        },
        serverCertificate: ''
      },
      playready: {
        LA_URL: 'POLLYCON_LICENSE_SERVER_URL',
        headers: {
          'pallycon-customdata-v2' : 'POLLYCON_LICENSE_TOKEN'
        }
      },
      fairplay: {
        LA_URL: 'POLLYCON_LICENSE_SERVER_URL',
        headers: {
          'pallycon-customdata-v2' : 'POLLYCON_LICENSE_TOKEN'
        },
        certificateURL: 'CERTIFICATE_URL',
        prepareContentId: function (contentId) {
          return contentId.substring(contentId.indexOf('skd://') + 6);
        },
        prepareCertificate: function (rawResponse) {
          var responseText = String.fromCharCode.apply(null, new Uint8Array(rawResponse));
          var raw = window.atob(responseText);
          var rawLength = raw.length;
          var certificate = new Uint8Array(new ArrayBuffer(rawLength));

          for (var i = 0; i < rawLength; i++)
            certificate[i] = raw.charCodeAt(i);

          return certificate;
        },
        useUint16InitData: true
      }
    }
  };

Please replace the following placeholders in the code:

  • HLS_MANIFEST_URL: The URL to the HLS manifest (M3U8) file.
  • DASH_MANIFEST_URL: The URL to the DASH manifest (mpd) file.
  • POLLYCON_LICENSE_SERVER_URL: DRM License Server URL provided by Pollycon.
  • CERTIFICATE_URL: The URL to the Fairplay certificate. This needs to be accessible for the player.
  • POLLYCON_LICENSE_TOKEN: The token provided by Pollycon.