Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including videojs-fairplay with all npm packages installed. Try it out:

var videojsFairplay = require("videojs-fairplay")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

videojs-fairplay v0.2.0

Video.js tech for supporting Fairplay streaming.

videojs-fairplay

Video.js source handler for supporting Fairplay streaming.

Protected Content

This source handler only supports encrypted HLS playback. It does not contain any fallbacks. The premise is to use this in tandem with videojs-contrib-dash to support encrypted playback in all* browsers.

If the browser (a.k.a Safari) supports Encrypted Media Extensions and includes a Content Decryption Module, video.js will be able to playback protected content.

Getting Started

<script src="/path/to/videojs.fairplay.min.js"></script>

<script>
videojs('player_id').ready(function () {
  this.src({
    src: '/path/to/file.m3u8',
    type: 'application/x-mpegURL',

    protection: {
      keySystem: 'com.apple.fps.1_0',

      certificateUrl: '/path/to/certificate',
      licenseUrl: '/path/to/license',
    },
  });
});
</script>

Known Issues

SEE: https://forums.developer.apple.com/thread/60276

  1. Fairplay content cannot be played if TextTracks exist. Beyond embedding them within the manifest, the only way to side load them is after the keys are updated.
videojs('player_id').ready(function () {
  var player = this;

  player.on('loadeddata', function () {
    player.addRemoteTextTrack(...);
  });
});
  1. New Fairplay content cannot be played once MediaKeys have been attached to the video element (Unless its the same source). To get around this issue we need to clear those keys.
player.reset();

player.src(...);
  1. Combining the issues of #1 and #2. Before you can play another source, you must clear out the existing TextTracks.
player.remoteTextTracks().tracks_.forEach(function (track) {
  player.removeRemoteTextTrack(track);
});

// the current `TextTrack` implementation operates on events and because of this we have to wait a
// tick before executing a reset, otherwise the `TextTrack`s will get picked up in its associated `Tech`.
setTimeout(function () {
  player.reset();

  player.src(...);
}, 0);

Contributing + Example

npm install -g grunt-cli # only needed for contributing

npm install

npm start

License

Code licensed under The MIT License.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free