productLogo

Shaka

Shaka Player is a JavaScript library for adaptive video streaming. It plays DASH content without browser plugins using MediaSource Extensions and Encrypted Media Extensions.

The vuplay-shaka repository demonstrates at a lower level how to integrate VUDRM with Googles’ Shaka player.

Basic setup

<div id="video"></div>
var streamUrl = "<your-stream-url>";
var vudrmToken = "<your-vudrm-token>";
var shakaPlayer;

shaka.polyfill.installAll();
if (shaka.Player.isBrowserSupported()) {
  var video = document.getElementById("video");
  shakaPlayer = new shaka.Player(video);
  shakaPlayer.addEventListener("error", onErrorEvent);
}

Widevine example

shakaPlayer.configure({
  drm: {
    servers: {
      "com.widevine.alpha": "https://widevine-proxy.drm.technology/proxy"
    }
  }
});

shakaPlayer
  .getNetworkingEngine()
  .registerRequestFilter(function(type, request) {
    if (type != shaka.net.NetworkingEngine.RequestType.LICENSE) return;

    var selectedDrmInfo = shakaPlayer.drmInfo();
    if (selectedDrmInfo.keySystem !== "com.widevine.alpha") {
      return;
    }

    var keyId = selectedDrmInfo.keyIds[0].toUpperCase();

    var body = {
      token: vudrmToken,
      drm_info: Array.apply(null, new Uint8Array(request.body)),
      kid: keyId
    };
    body = JSON.stringify(body);
    request.body = body;
    request.headers["Content-Type"] = "application/json";
  });

shakaPlayer
  .load(streamUrl)
  .then(function() {
    console.log("The stream has now been loaded!");
  })
  .catch(onError);

PlayReady example

var playReadyLaURL =
  "https://playready-license.drm.technology/rightsmanager.asmx?token=" +
  encodeURIComponent(vudrmToken);
shakaPlayer.configure({
  drm: {
    servers: {
      "com.microsoft.playready": playReadyLaURL
    }
  }
});

shakaPlayer
  .load(streamUrl)
  .then(function() {
    console.log("The stream has now been loaded!");
  })
  .catch(onError);

No FairPlay support

Shaka does not currently support FairPlay.