How to use the video player
Overview
The VideoJS DRM Player demo wraps the
VideoJSDRMPlayer package (Video.js + Shaka Player) with a configuration
form and a live JSON preview of the options passed to the player — including
drmConfig when DRM is enabled.
Prerequisites:
- PHP backend running (default:
http://localhost:8000) - For DRM playback: license delivery mode configured — see Token Authorization or Callback Authorization.
- A DRM-protected stream URL (e.g. from the CPIX Packager)
Using the VideoJS demo UI
- Open Player Demos → View Demo on the VideoJS card, or go directly to videojs-demo.html.
-
In the right panel (Configuration Settings), enter a
Video/Audio Source URL (HLS
.m3u8or DASH.mpd). - Adjust playback options (autoplay, loop, aspect ratio, poster, etc.) as needed.
- To play DRM content, check Enable DRM. The License delivery authorization and DRM Configuration sections appear.
- Click Load Video to initialize the player.
-
Use the Player Options panel (left side) to inspect or copy the full
JSON configuration, including
drmConfig.
Player options reference
| Option | Form field | Description |
|---|---|---|
containerId |
— | Fixed to videojs-container in the demo |
source |
Video/Audio Source URL | Manifest or media URL (required) |
totalWidth / totalHeight |
Width / Height | Player dimensions (e.g. 800px, 80%) |
useShakaTech |
Use Shaka Tech | Use Shaka Player for adaptive streaming (recommended) |
isDRM |
Enable DRM | Enable DRM license handling |
drmConfig |
DRM Configuration | Per-DRM-system license URLs and headers (see below) |
autoplay, loop, muted |
Checkboxes | Standard playback flags |
aspectRatio |
Aspect Ratio | e.g. 16:9, 4:3 |
poster |
Poster | Poster image URL |
fluid |
Fluid | Responsive fluid layout |
classicControls |
Use Classic Controls | Use built-in Video.js controls instead of custom controls |
audioOnlyMode |
Audio Only Mode | Adapt UI for audio-only streams |
displayFormat |
Display Format | Audio-only UI layout (1–4) |
Configuring drmConfig
When isDRM: true, the player expects a drmConfig object with
entries for the target DRM system. Each entry has:
url— license server URLlicenseHeaders— HTTP headers sent with the license requestcertificateUrl— (FairPlay only) FPS certificate URL
Basic structure:
{
"isDRM": true,
"source": "https://your-server/packaged-video.ism/.m3u8",
"drmConfig": {
"widevine": {
"url": "https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/?specConform=true&assetId=CPIX-test",
"licenseHeaders": {
"x-dt-auth-token": "<jwt-token>"
}
}
}
}
The demo builds drmConfig automatically from the form fields and the
current license delivery method. You can also construct it manually when integrating
the player in your own application.
TOKEN (Upfront) mode
When the organization's license delivery mode is TOKEN (DRMtoday
UPFRONT):
-
The demo fetches the current mode from
apis/license-delivery-authorization/status.php. - Only Asset ID is required in the DRM Configuration form (User ID, Session ID, and Merchant fields are hidden).
-
On Load Video, the demo calls
apis/license-delivery-authorization/get-auth-token.phpwith{ "assetId": "..." }. -
The returned JWT is placed in
licenseHeadersunderx-dt-auth-token(or the header name returned by the API).
Example drmConfig for Widevine in TOKEN mode:
"drmConfig": {
"widevine": {
"url": "https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/?specConform=true&assetId=CPIX-test",
"licenseHeaders": {
"x-dt-auth-token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ii4uLiJ9..."
}
}
}
Use the Switch to CALLBACK button in the License delivery authorization panel to change modes without leaving the demo (calls the set-method API).
CALLBACK mode
When the mode is CALLBACK, DRMtoday validates each license request by calling your backend callback URL. The demo sends custom data in the license header instead of a JWT.
Required form fields:
- User ID
- Session ID
- Merchant (Organization ID)
- Asset ID
Example drmConfig for Widevine in CALLBACK mode:
"drmConfig": {
"widevine": {
"url": "https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/?specConform=true&assetId=CPIX-test",
"licenseHeaders": {
"x-dt-custom-data": "eyJ1c2VySWQiOiJyZW50YWwxIiwibWVyY2hhbnQiOiIuLi4iLCJzZXNzaW9uSWQiOiJwMCJ9"
}
}
}
The x-dt-custom-data value is a Base64-encoded JSON object:
{ userId, merchant, sessionId }.
DRM system URLs
| DRM Type | Form value | License URL (staging) | Extra fields |
|---|---|---|---|
| Widevine | widevine |
https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/?specConform=true&assetId={assetId}
|
— |
| FairPlay | fairplay |
https://lic.staging.drmtoday.com/license-server-fairplay/ |
certificateUrl:
.../license-server-fairplay/cert/{merchant}
|
| PlayReady | playready |
https://lic.staging.drmtoday.com/license-proxy-headerauth/drmtoday/RightsManager.asmx
|
— |
Select the DRM type that matches your browser: Widevine for Chrome/Firefox, FairPlay for Safari, PlayReady for Edge (Windows).
Programmatic initialization
Minimal example without the demo form:
const player = new VideoJSDRMPlayer({
containerId: "videojs-container",
source: "https://your-server/packaged-video.ism/.m3u8",
useShakaTech: true,
isDRM: true,
drmConfig: {
widevine: {
url: "https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/?specConform=true&assetId=CPIX-test",
licenseHeaders: {
"x-dt-auth-token": authTokenFromYourBackend
}
}
}
});
In production, fetch the auth token from your own backend — never embed shared secrets or long-lived tokens in client-side code. See also the VideoJS package documentation for build and integration details.