License¶
Every PRESTOplay deployment requires a Castlabs license key. This page covers how license keys work, how domain locking applies, and how to identify viewers.
Castlabs license¶
A Castlabs license key is required to enable the player and unlock its features. Get a license key.
Provide the license key and viewerId when creating the player:
const player = new clpp.Player('video', {
license: '<your_license_key>',
viewerId: '<user_id>',
});
License domain lock¶
Castlabs license keys are tied to one domain or a set of domains. The player works only when your app is served from an allowed domain.
Development¶
localhost and private network IP addresses are allowed by default for
local development and work even without a license key.
Viewer ID¶
The viewer ID must uniquely identify the end user of your application.
Castlabs license keys require a viewerId, so pass it together with the
license key when creating the player. Depending on your contract with
Castlabs, viewerId might not be required; in that case, you can omit it.
const player = new clpp.Player('video', {
license: '<your_license_key>',
viewerId: '5125412-e8809b0-689328e-0a38f476',
});
If you don’t specify viewerId, drm.customData.userId is used as a
fallback:
const player = new clpp.Player('video', {
license: '<your_license_key>',
drm: {
customData: {
userId: '5125412-e8809b0-689328e-0a38f476',
sessionId: 'e43b0c9302d4558f39b76d2d05e5e21eb00b3b28',
},
},
});
License verification¶
License verification requests run against a secure HTTPS origin. Serve your application over HTTPS so verification succeeds.
If license verification fails, the player reports an error and stops
playback. Listen for clpp.events.ERROR and inspect the error code:
import { clpp } from "@castlabs/prestoplay";
import "@castlabs/prestoplay/cl.mse";
import "@castlabs/prestoplay/cl.dash";
const player = new clpp.Player('video', {
license: '<your_license_key>',
viewerId: '<user_id>',
});
player.on(clpp.events.ERROR, (e) => {
const error = e.detail;
if (error.code === clpp.Error.Code.INVALID_LICENSE) {
// The license key is invalid.
}
if (error.code === clpp.Error.Code.USER_ID_NOT_PROVIDED) {
// The license requires a viewer ID, but neither `viewerId`
// nor `drm.customData.userId` was provided.
}
});
player.open({
source: 'https://cdn.com/manifest.mpd',
});
For the full list of error codes, see Errors.