Skip to content

DRM protection

MKPlayer supports Widevine, PlayReady, and FairPlay DRM. You configure DRM by adding a drm property to your MKSourceConfig before calling player.load(). The player selects the first key system supported by the current platform.

To support playback across browsers and devices, it is recommended to provide both a Widevine and a PlayReady configuration. FairPlay applies only to HLS sources on Apple devices.

You have an initialised MKPlayer instance and a loaded source. See Installation and setup and Loading and playing content.

Add a drm object to your source configuration. Each key system is optional — include only the ones your licence server supports:

const sourceConfig = {
title: "Protected Stream",
hls: "https://my-cdn.com/mysource/hls/index.m3u8",
dash: "https://my-cdn.com/mysource/dash/manifest.mpd",
drm: {
widevine: {
LA_URL: "https://your-widevine-license-server/license",
headers: {
"X-CustomHeader": "custom-value"
}
},
playready: {
LA_URL: "https://your-playready-license-server/license",
headers: {
"X-CustomHeader": "custom-value"
}
},
fairplay: {
LA_URL: "https://your-fairplay-license-server/license",
certificateURL: "https://your-fairplay-certificate-url",
headers: {
"X-CustomHeader": "custom-value"
}
}
}
};
player.load(sourceConfig);

Both widevine and playready accept the same core properties:

PropertyTypeDescription
LA_URLstringURL of the DRM licence server.
headersMKHeadersCustom HTTP headers sent with licence requests.

Most smart TV platforms require plaintextChallenge and utf8message to be set for PlayReady licence requests to succeed:

playready: {
LA_URL: "https://your-playready-license-server/license",
utf8message: true,
plaintextChallenge: true,
headers: {
"Content-Type": "text/xml"
}
}

FairPlay requires a certificateURL in addition to the licence server URL. It applies only to HLS sources on Apple devices.

PropertyTypeDescription
LA_URLstringURL of the FairPlay licence server.
certificateURLstringURL to the FairPlay certificate. Required.
headersMKHeadersCustom HTTP headers for licence requests.
certificateHeadersMKHeadersCustom HTTP headers for the certificate request.
prepareContentIdfunctionCallback to transform the content ID extracted from the HLS manifest before it is sent to the licence server.
prepareMessagefunctionCallback to prepare the licence acquisition message before it is sent.
prepareLicensefunctionCallback to transform the licence response before it is passed to the browser.
prepareCertificatefunctionCallback to transform the certificate response before it is passed to the browser.
withCredentialsbooleanSend cookies and auth headers with licence requests. Default: false.
licenseResponseTypeMKHttpResponseTypeSets an explicit response type for the licence request. Default: TEXT.
useUint16InitDatabooleanUse Uint16Array instead of Uint8Array for init data. Depends on your FairPlay licence server. Default: false.
maxLicenseRequestRetriesnumberHow many times to retry a failed licence request. Default: 1. Set to 0 to disable retries.
maxCertificateRequestRetriesnumberHow many times to retry a failed certificate request. Default: 1. Set to 0 to disable retries.
Error codeMeaning
PLAYER_DRM_FAILED_LICENSE_REQUESTThe licence request failed. Check that LA_URL is correct and that required headers and tokens are present.
PLAYER_DRM_NO_KEY_SYSTEMThe current platform does not support any of the key systems in the source config.
PLAYER_DRM_CERTIFICATE_ERRORThe FairPlay certificate could not be loaded or parsed. Check certificateURL.
PLAYER_DRM_INIT_DATA_MISSINGNo DRM init data was found in the manifest or segments. Check your stream packaging.
PLAYER_DRM_RESTRICTED_OUTPUTThe device cannot securely present the content, for example due to a non-HDCP display.
PLAYER_NO_DRM_LICENSE_SERVER_URL_PROVIDEDLA_URL is missing or invalid in the DRM config.

See Events and error handling for how to listen for and respond to DRM errors at runtime.

© 2026 MediaKind. All rights reserved.