videojs-contrib-eme icon indicating copy to clipboard operation
videojs-contrib-eme copied to clipboard

getLicense should pass the event object

Open tidemann opened this issue 7 years ago • 5 comments

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?

tidemann avatar Nov 22 '18 13:11 tidemann

+1

slasktrat avatar Jan 22 '19 12:01 slasktrat

+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 avatar Mar 28 '19 22:03 chakrikodali

@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 avatar Mar 28 '19 23:03 squarebracket

@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

chakrikodali avatar Mar 29 '19 20:03 chakrikodali

+1

chadacious avatar Jan 07 '21 22:01 chadacious