Test DRM Playback
After creating a content key policy and streaming locator, test that your encrypted streams play correctly. MK.IO provides the MKPlayer testing page for quick validation. For integration into your own application, use the MKPlayer SDK.
Test with MKPlayer
Get the playback and license URLs
- Navigate to the Assets page and select your asset.
- Select the streaming locator and a running streaming endpoint.
- Select Apply to generate the URLs.
- Copy the playback URL for your chosen protocol (HLS or DASH).
- Copy the license acquisition URL for your DRM system (Widevine, PlayReady, FairPlay, or ClearKey).
Configure MKPlayer
- Navigate to the MKPlayer page.
- Select the protocol (HLS or DASH).
- Select the DRM system that matches your content key policy.
- Paste the playback URL in Source URL.
- Paste the license acquisition URL in License URL.
Add authorization (token-protected content)
If your content key policy uses token restriction, add the JWT token in the License request headers field:
{"Authorization": "Bearer <your-jwt-token>"}See JWT token authentication to generate a token.
Play
Select Play. If the configuration is correct, the player decrypts and plays the stream.
Troubleshooting playback errors
| Error | Cause | Solution |
|---|---|---|
DRM_FAILED_LICENSE_REQUEST | Missing or invalid JWT token. | Verify the token and add it to the license request headers. |
| License URL not populated | Streaming locator not applied. | Select Apply on the streaming locator to generate URLs. |
| Playback fails on specific browser | DRM system not supported on that browser. | Select the correct DRM for the browser. See DRM support by platform. |
Configure the MKPlayer SDK
For integration into your own application, use the MKPlayer SDK to configure DRM playback programmatically.
Prerequisites
- Install the latest version of MKPlayer SDK (opens in a new tab).
- Complete the Getting Started steps in the MKPlayer documentation (opens in a new tab).
Build the source configuration
Create a source configuration object with your playback URLs and DRM license URLs. You can include multiple DRM systems in the configuration. The player automatically selects the most suitable one for the current platform.
const sourceConfig = {
title: "Title for your source",
description: "Description for your source",
hls: "HLS URL as copied from the Assets page",
dash: "DASH URL as copied from the Assets page",
drm: {
// For Safari Browser with HLS + FairPlay Content Protection
fairplay: {
LA_URL: "FairPlay License URL as copied from the Assets page",
certificateURL: "FairPlay Certificate URL as copied from the Assets page",
headers: {
"Authorization": "Bearer <jwtToken>"
}
},
// For Chrome, Edge browsers
widevine: {
LA_URL: "Widevine License URL as copied from the Assets page",
headers: {
"Authorization": "Bearer <jwtToken>"
}
},
// For Edge (Windows) browser
playready: {
LA_URL: "PlayReady License URL as copied from the Assets page",
headers: {
"Authorization": "Bearer <jwtToken>"
}
}
}
};Each platform or browser has a preferred DRM system. If you are uncertain which DRM to use, include all applicable systems in the configuration. The player selects the best match for the current environment.
Remove the headers objects if your content key policy does not use token restriction.
Load and play
Pass the source configuration to the player:
player.load(sourceConfig)
.then(() => {
console.log("Source loaded successfully");
})
.catch((error) => {
console.error("An error occurred while loading the source");
});Refer to the MKPlayer documentation (opens in a new tab) for additional configuration options and event handling.