License ******* Castlabs license keys, domain locking, viewer IDs, and license verification for PRESTOplay for Web Apps. Castlabs license ================ A Castlabs license key is required to enable the player and unlock its features. Get a license key (https://account.castlabs.com/signup). Provide the license key and "viewerId" when creating the player: const player = new clpp.Player("video", { license: "", viewerId: "", }); 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: "", 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: "", drm: { customData: { userId: "5125412-e8809b0-689328e-0a38f476", sessionId: "e43b0c9302d4558f39b76d2d05e5e21eb00b3b28", }, }, }); License verification ==================== License verification requires HTTPS. If verification fails, the player reports an error during playback — listen for "clpp.events.ERROR". 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: "", viewerId: "", }); 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.