I develop custom Cast Receiver application based on Google Cast Application Framework The receiver app is responsible for playback Widevine encrypted streams. Our backed solution requires to add DRM token to PreAuthorization
header in license request. I need to perform a couple of authorized requests to retrieve the DRM token. I assumed that the best place to retrieve DRM token is to use Message Interceptor:
this.playerManager_.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD, (loadRequestData) => {
var media = loadRequestData.media;
var customData = media.customData;
var licenseUrl = customData.licenseUrl || null;
var contentId = media.contentId;
var cdn = customData.cdn || null;
return this.getOriginMediaURL(contentId, cdn, PlayerApiImp)
.then(playbackURL => {
loadRequestData.media.contentId = playbackURL;
loadRequestData.media.customData.contentUrl = contentId;
return this.getDRMToken(customData);
})
.then(drmToken => {
this.preAuthToken = drmToken
this.playbackConfig_.licenseUrl = licenseUrl;
return loadRequestData
})
.catch(error => {
this.log_({'ERROR': error});
return loadRequestData;
});;
});
Then CAST Player automatically calls licenseRequestHandler
and I easily add required DRM token to the headers of license request:
this.playbackConfig_.licenseRequestHandler = requestInfo => {
if (this.preAuthToken) {
requestInfo.headers = {};
requestInfo.headers['PreAuthorization'] = this.preAuthToken;
}
};
Playback works fine but until the time when license key has expired. On our backend license lives ~30min. After that time the receiver player generates error [cast.framework.media.ShakaPlayer] category: 6 code: 6014
and playback stops.
I found that this error means
So my questions are:
- Does Cast Receiver API support license renewing? What callbacks in CAST API does receiver trigger to notify that session has expired? I don't receive any, I only get error :( and playback stops.
- How I can provide new license to the player to prevent it from failing?