videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
203 stars 72 forks source link

config options #56

Closed slash197 closed 6 years ago

slash197 commented 6 years ago

I cannot find a specific way to implement custom headers with widevine, using the config below does not work. Any help is appreciated.

    _source = {
        src: 'https://02live00.akamaized.net/CLOUDTV_RTL8HD/Manifest.mpd',
        type: 'application/dash+xml',
        keySystemOptions: [{
            name: 'com.widevine.alpha',
            options: {
                licenseUrl: 'https://wv-keyos.licensekeyserver.com',
                httpRequestHeaders: {customdata: 'PEtleU9TQXV0aGVudGljYXRpb25YTUw+CjxEYXRhPg..........'}
            }
        }]
    };
squarebracket commented 6 years ago

It looks like you're using the configs from videojs/videojs-contrib-dash. They are not directly transferable. There is also no "simple field" for providing your own HTTP headers; you'll have to implement your own getLicense function, as shown here.

You'll want to do something like:

let source = {
  src: mySrc,
  type: 'application/dash+xml',
  keySystems = {
    'com.widevine.alpha': {
      getLicense: function(emeOptions, keyMessage, callback) {
        let message = new Uint8Array(keyMessage);
        videojs.xhr({
          uri: widevineUrl,
          method: 'POST',
          responseType: 'arraybuffer',
          body: message,
          headers: myHeaders
        }, (err, response, responseBody) => {
          if (err) {
            callback(err);
            return;
          }
          callback(null, responseBody);
        });
      }
    }
  }
};
slash197 commented 6 years ago

Thank you for the details, appreciate it.