Playing protected content with DRMtoday
Overview
If you are not sure what DRM is, you want have an overview and get started, please have a look at our DRM Setup Guide.
Nearly every license provider, such as Irdeto or EZDRM, requires a few special information being sent to the DRM license server, or responds with a proprietary format. Instead of integrating a few license providers into the core of our player, we decided to provide necessary configuration options via the player configuration.
Widevine
var conf = {
key: 'YOUR-PLAYER-KEY-HERE',
source: {
dash: '//example.com/path/to/your/manifest.mpd',
drm: {
widevine: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
headers: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
prepareLicense : function(licenseObj) {
var license = {license: licenseObj.license};
try {
var drmTodayObj = JSON.parse(String.fromCharCode.apply(null, licenseObj.license));
if (drmTodayObj && drmTodayObj.status && drmTodayObj.license) {
if (drmTodayObj.status === 'OK') {
var str = window.atob(drmTodayObj.license);
var bufView = new Uint8Array(new ArrayBuffer(str.length));
for (var i = 0; i < str.length; i++) {
bufView[i] = str.charCodeAt(i);
}
license.license = bufView;
} else {
// license not okay
}
} else {
// no valid DRMtoday license
}
} catch (e) {
// no valid DRMtoday license
}
return license;
}
}
}
}
}
PlayReady
var conf = {
key: 'YOUR-PLAYER-KEY-HERE',
source: {
dash: '//example.com/path/to/your/manifest.mpd',
drm: {
playready: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
headers: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
}
}
}
}
FairPlay
var conf = {
key: 'YOUR-PLAYER-KEY-HERE',
source: {
hls: '//example.com/path/to/your/master-playlist.m3u8',
drm: {
fairplay: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
certificateURL: 'https://certificate-url-provided-by-drmtoday',
certificateHeaders: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
headers: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
prepareMessage : function(event, session) {
return 'spc=' + encodeURIComponent(event.messageBase64Encoded) + '&' + session.contentId;
},
prepareContentId : function(contentId) {
var pattern='skd://drmtoday?';
var idx = contentId.indexOf(pattern);
if (idx > -1) {
var parameters = contentId.substring(idx + pattern.length);
parameters = parameters.replace(/assetid/gi, 'assetId');
parameters = parameters.replace(/variantid/gi, 'variantId');
parameters = parameters.replace(/&keyId\=.*/gi, "");
return parameters;
} else {
return '';
}
}
}
}
}
}
Adobe Access (Flash Fallback)
var conf = {
key: 'YOUR-PLAYER-KEY-HERE',
source: {
dash: '//example.com/path/to/your/manifest.mpd',
drm: {
access: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
authToken: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
}
}
}
}
Complete example for Widevine, PlayReady, Access and FairPlay
var conf = {
key: 'YOUR-PLAYER-KEY-HERE',
source: {
dash: '//example.com/path/to/your/manifest.mpd',
hls: '//example.com/path/to/your/master-playlist.m3u8',
drm: {
widevine: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
headers: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
prepareLicense : function(licenseObj) {
var license = {license: licenseObj.license};
try {
var drmTodayObj = JSON.parse(String.fromCharCode.apply(null, licenseObj.license));
if (drmTodayObj && drmTodayObj.status && drmTodayObj.license) {
if (drmTodayObj.status === 'OK') {
var str = window.atob(drmTodayObj.license);
var bufView = new Uint8Array(new ArrayBuffer(str.length));
for (var i = 0; i < str.length; i++) {
bufView[i] = str.charCodeAt(i);
}
license.license = bufView;
} else {
// license not okay
}
} else {
// no valid DRMtoday license
}
} catch (e) {
// no valid DRMtoday license
}
return license;
}
},
playready: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
headers: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
},
fairplay: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
certificateURL: 'https://certificate-url-provided-by-drmtoday',
certificateHeaders: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
headers: {
'x-dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
},
prepareMessage : function(event, session) {
return 'spc=' + encodeURIComponent(event.messageBase64Encoded) + '&' + session.contentId;
},
prepareContentId : function(contentId) {
var pattern='skd://drmtoday?';
var idx = contentId.indexOf(pattern);
if (idx > -1) {
var parameters = contentId.substring(idx + pattern.length);
parameters = parameters.replace(/assetid/gi, 'assetId');
parameters = parameters.replace(/variantid/gi, 'variantId');
parameters = parameters.replace(/&keyId\=.*/gi, "");
return parameters;
} else {
return '';
}
}
},
access: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
authToken: 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA'
}
}
}
}
Updated about 1 month ago