videojs-contrib-eme
videojs-contrib-eme copied to clipboard
getLicense should pass the event object
I'm making a react app with videojs (7.2.3) with fairplay support using videojs-contrib-eme (3.4.1) and I have some problems with implementing the getLicense function properly
The function is triggered in contrib-eme like this (from fairplay.js):
keySession.addEventListener('webkitkeymessage', function (event) {
getLicense(options, contentId, event.message,event.target, function (err, license) {...}
}
In order to make a valid request to the license server, I need the event.target (keySession) object (this contains the required sessionid) passed to the getLicense function
In Apple's sample implementation the webkitkeymessage event is handled like this:
waitForEvent('webkitkeymessage', licenseRequestReady, keySession);
function licenseRequestReady(event)
{
var session = event.target;
var message = event.message;
var request = new XMLHttpRequest();
var sessionId = event.sessionId;
request.responseType = 'text';
request.session = session;
request.addEventListener('load', licenseRequestLoaded, false);
request.addEventListener('error', licenseRequestFailed, false);
var params = 'spc='+base64EncodeUint8Array(message)+'&assetId='+encodeURIComponent(session.contentId);
request.open('POST', serverProcessSPCPath, true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send(params);
}
I guess the entire event object should be passed to getLicense and not just event.message?
+1
+1
I need access to keySession object to add listener on webkitkeyerror event. I am not able to get handle of HDCP error fired from keySession when some tries to stream playback through HDMI port.
@chakrikodali do you have a source for being able to handle HDCP errors? As far as I know, no such event detection is possible in Safari.
@squarebracket i don't have source to handle hdcp errors. But what i have seen is, an error thrown here(https://github.com/videojs/videojs-contrib-eme/blob/master/src/fairplay.js#L97) when i plugin hdmi. Which never gets bubbled up as the promise is already resolved when licensekey got added to keySession(https://github.com/videojs/videojs-contrib-eme/blob/master/src/fairplay.js#L90).
Error - KeySession error: code 6, systemCode 1212433232
+1