Skip to content
Merged
5 changes: 2 additions & 3 deletions theoplayer/examples/_components/DrmDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from '../shared.module.css';
type SourceName = 'drm' | 'aes';

const sourceLabels: Record<SourceName, string> = {
drm: 'DRM: Widevine or PlayReady (DASH), FairPlay (HLS)',
drm: 'DRM: Widevine, PlayReady or FairPlay (HLS)',
aes: 'AES-128 (HLS)',
};

Expand All @@ -18,8 +18,7 @@ const keySystems: Record<string, string> = {

function describeSource(src: string | undefined): string {
if (!src) return '-';
if (src.includes('dash-wv-pr')) return 'DASH with Widevine or PlayReady';
if (src.includes('hls-fp')) return 'HLS with FairPlay';
if (src.includes('protected_1080p_h264_cbcs')) return 'HLS with Widevine, PlayReady or FairPlay';
if (src.includes('encrypted')) return 'HLS with AES-128';
return src;
}
Expand Down
49 changes: 49 additions & 0 deletions theoplayer/examples/_components/FeatureModulesDemo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React, { type JSX, useState } from 'react';
import useBaseUrl from '@docusaurus/useBaseUrl';
import Example from '@site/src/components/Example';
import styles from '../shared.module.css';

interface FeatureModulesState {
modules: string[];
features: string[];
version: string;
}

export default function FeatureModulesDemo(): JSX.Element {
const [state, setState] = useState<FeatureModulesState | undefined>(undefined);

return (
<>
<Example
src={useBaseUrl('/theoplayer/v11/examples/feature-modules/demo.html')}
onMessage={(message) => {
if (message.type === 'feature-modules') {
setState({
modules: message.modules as string[],
features: message.features as string[],
version: message.version as string,
});
}
}}
/>
<div className={styles.panel}>
<table className={styles.readout}>
<tbody>
<tr>
<th>Imported modules</th>
<td>{state ? state.modules.join(', ') : '…'}</td>
</tr>
<tr>
<th>THEOplayer.features</th>
<td>{state ? JSON.stringify(state.features) : '…'}</td>
</tr>
<tr>
<th>THEOplayer.version</th>
<td>{state ? state.version : '…'}</td>
</tr>
</tbody>
</table>
</div>
</>
);
}
8 changes: 4 additions & 4 deletions theoplayer/examples/content-protection/01-drm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import DrmDemo from '../_components/DrmDemo';

This example plays protected content:

- **DRM**: a single source description with a DASH stream protected with Widevine and PlayReady, and an HLS stream protected with FairPlay.
The player picks the first stream that the current browser supports: Widevine or PlayReady in most browsers, and FairPlay in Safari.
The license requests are handled by the KeyOS [DRM integration](../../how-to-guides/web/drm/buydrm-keyos.mdx).
- **DRM**: an HLS stream protected with Widevine, PlayReady and FairPlay.
The player uses the key system that the current browser supports: Widevine or PlayReady in most browsers, and FairPlay in Safari.
The license requests are handled by the Axinom [DRM integration](../../how-to-guides/web/drm/axinom.mdx).
- **AES-128**: an HLS stream encrypted with AES-128. The player fetches the decryption key from the URL in the HLS playlist, so no extra configuration is needed.

The box below the player shows which stream the player selected, and which DRM key systems your browser supports.
The box below the player shows which stream the player is playing, and which DRM key systems your browser supports.

<details>
<summary>Code</summary>
Expand Down
37 changes: 37 additions & 0 deletions theoplayer/examples/getting-started/02-feature-modules.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_custom_props: { icon: '🧩' }
description: Import only the player features your app needs with feature modules, and check which features are enabled.
---

# Feature modules

import CodeBlock from '@theme/CodeBlock';
import demoSource from '!!raw-loader!../../static/theoplayer/v11/examples/feature-modules/demo.html';
import FeatureModulesDemo from '../_components/FeatureModulesDemo';

<FeatureModulesDemo />

Since version 11.16.0, the Web SDK ships every feature as a separate module.
This example imports the player without any features from `theoplayer/core`, and adds HLS playback with `theoplayer/hls`:

```js
import * as THEOplayer from 'theoplayer/core';
import 'theoplayer/hls';
import '@theoplayer/web-ui';
```

`THEOplayer.features` lists the features that are enabled, so the box below the player only shows `hls`.
Import every feature module before the player is created.

This example loads the packages from a CDN with an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap).
Open Video UI imports the player from `theoplayer/chromeless`, so the import map points that name to `theoplayer/core` as well.
In your application, install `theoplayer` and `@theoplayer/web-ui` from npm and bundle them instead.

See [How to use THEOplayer feature modules](../../getting-started/01-sdks/01-web/14-how-to-use-feature-modules.md) for all available modules.

<details>
<summary>Code</summary>
<CodeBlock language="html" title="demo.html" showLineNumbers>
{demoSource}
</CodeBlock>
</details>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<!-- Conviva core SDK (exposes the global Conviva object) -->
<script src="https://unpkg.com/@convivainc/conviva-js-coresdk@4.9.0/conviva-core-sdk.js"></script>
<!-- THEOplayer Conviva connector (exposes THEOplayerConvivaConnector) -->
<script src="https://unpkg.com/@theoplayer/conviva-connector-web@3.3.2/dist/conviva-connector.umd.js"></script>
<script src="https://unpkg.com/@theoplayer/conviva-connector-web@3/dist/conviva-connector.umd.js"></script>
</head>
<body>
<!--
Expand Down
20 changes: 10 additions & 10 deletions theoplayer/static/theoplayer/v11/examples/debug-display/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
{
"imports": {
"theoplayer/chromeless": "https://cdn.theoplayer.com/dash/theoplayer/THEOplayer.chromeless.esm.js",
"@theoplayer/web-ui": "https://ga.jspm.io/npm:@theoplayer/web-ui@2.6.1/dist/THEOplayerUI.mjs",
"@theoplayer/web-ui/debug": "https://ga.jspm.io/npm:@theoplayer/web-ui@2.6.1/dist/THEOplayerUI.debug.mjs",
"lit": "https://ga.jspm.io/npm:lit@3.3.1/index.js",
"lit/decorators.js": "https://ga.jspm.io/npm:lit@3.3.1/decorators.js",
"lit/directives/": "https://ga.jspm.io/npm:lit@3.3.1/directives/"
"@theoplayer/web-ui": "https://unpkg.com/@theoplayer/web-ui@2/dist/THEOplayerUI.mjs",
"@theoplayer/web-ui/debug": "https://unpkg.com/@theoplayer/web-ui@2/dist/THEOplayerUI.debug.mjs",
"lit": "https://ga.jspm.io/npm:lit@3.3.2/index.js",
"lit/decorators.js": "https://ga.jspm.io/npm:lit@3.3.2/decorators.js",
"lit/directives/": "https://ga.jspm.io/npm:lit@3.3.2/directives/"
},
"scopes": {
"https://ga.jspm.io/": {
"@lit/reactive-element": "https://ga.jspm.io/npm:@lit/reactive-element@2.1.1/reactive-element.js",
"@lit/reactive-element/decorators/": "https://ga.jspm.io/npm:@lit/reactive-element@2.1.1/decorators/",
"lit-element/lit-element.js": "https://ga.jspm.io/npm:lit-element@4.2.1/lit-element.js",
"lit-html": "https://ga.jspm.io/npm:lit-html@3.3.1/lit-html.js",
"lit-html/": "https://ga.jspm.io/npm:lit-html@3.3.1/"
"@lit/reactive-element": "https://ga.jspm.io/npm:@lit/reactive-element@2.1.2/reactive-element.js",
"@lit/reactive-element/decorators/": "https://ga.jspm.io/npm:@lit/reactive-element@2.1.2/decorators/",
"lit-element/lit-element.js": "https://ga.jspm.io/npm:lit-element@4.2.2/lit-element.js",
"lit-html": "https://ga.jspm.io/npm:lit-html@3.3.2/lit-html.js",
"lit-html/": "https://ga.jspm.io/npm:lit-html@3.3.2/"
}
}
}
Expand Down
49 changes: 21 additions & 28 deletions theoplayer/static/theoplayer/v11/examples/drm/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
></theoplayer-default-ui>
<script src="../utils.js"></script>
<script>
// A test token for the KeyOS license server.
const keyosCustomData =
'PEtleU9TQXV0aGVudGljYXRpb25YTUw+PERhdGE+PEdlbmVyYXRpb25UaW1lPjIwMTYtMTEtMTkgMDk6MzQ6MDEuOTkyPC9HZW5lcmF0aW9uVGltZT48RXhwaXJhdGlvblRpbWU+MjAyNi0xMS0xOSAwOTozNDowMS45OTI8L0V4cGlyYXRpb25UaW1lPjxVbmlxdWVJZD4wZmZmMTk3YWQzMzQ0ZTMyOWU0MTA0OTIwMmQ5M2VlYzwvVW5pcXVlSWQ+PFJTQVB1YktleUlkPjdlMTE0MDBjN2RjY2QyOWQwMTc0YzY3NDM5N2Q5OWRkPC9SU0FQdWJLZXlJZD48V2lkZXZpbmVQb2xpY3kgZmxfQ2FuUGxheT0idHJ1ZSIgZmxfQ2FuUGVyc2lzdD0iZmFsc2UiIC8+PFdpZGV2aW5lQ29udGVudEtleVNwZWMgVHJhY2tUeXBlPSJIRCI+PFNlY3VyaXR5TGV2ZWw+MTwvU2VjdXJpdHlMZXZlbD48L1dpZGV2aW5lQ29udGVudEtleVNwZWM+PEZhaXJQbGF5UG9saWN5IC8+PExpY2Vuc2UgdHlwZT0ic2ltcGxlIiAvPjwvRGF0YT48U2lnbmF0dXJlPk1sNnhkcU5xc1VNalNuMDdicU8wME15bHhVZUZpeERXSHB5WjhLWElBYlAwOE9nN3dnRUFvMTlYK1c3MDJOdytRdmEzNFR0eDQydTlDUlJPU1NnREQzZTM4aXE1RHREcW9HelcwS2w2a0JLTWxHejhZZGRZOWhNWmpPTGJkNFVkRnJUbmxxU21raC9CWnNjSFljSmdaUm5DcUZIbGI1Y0p0cDU1QjN4QmtxMUREZUEydnJUNEVVcVJiM3YyV1NueUhGeVZqWDhCR3o0ZWFwZmVFeDlxSitKbWI3dUt3VjNqVXN2Y0Fab1ozSHh4QzU3WTlySzRqdk9Wc1I0QUd6UDlCc3pYSXhKd1ZSZEk3RXRoMjhZNXVEQUVZVi9hZXRxdWZiSXIrNVZOaE9yQ2JIVjhrR2praDhHRE43dC9nYWh6OWhVeUdOaXRqY2NCekJvZHRnaXdSUT09PC9TaWduYXR1cmU+PC9LZXlPU0F1dGhlbnRpY2F0aW9uWE1MPg==';
// A test token for the Axinom license servers.
const axinomToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJ2ZXJzaW9uIjogMSwKICAiY29tX2tleV9pZCI6ICI2OWU1NDA4OC1lOWUwLTQ1MzAtOGMxYS0xZWI2ZGNkMGQxNGUiLAogICJtZXNzYWdlIjogewogICAgInR5cGUiOiAiZW50aXRsZW1lbnRfbWVzc2FnZSIsCiAgICAidmVyc2lvbiI6IDIsCiAgICAibGljZW5zZSI6IHsKICAgICAgImFsbG93X3BlcnNpc3RlbmNlIjogdHJ1ZQogICAgfSwKICAgICJjb250ZW50X2tleXNfc291cmNlIjogewogICAgICAiaW5saW5lIjogWwogICAgICAgIHsKICAgICAgICAgICJpZCI6ICIzMDJmODBkZC00MTFlLTQ4ODYtYmNhNS1iYjFmODAxOGEwMjQiLAogICAgICAgICAgImVuY3J5cHRlZF9rZXkiOiAicm9LQWcwdDdKaTFpNDNmd3YremZ0UT09IiwKICAgICAgICAgICJ1c2FnZV9wb2xpY3kiOiAiUG9saWN5IEEiCiAgICAgICAgfQogICAgICBdCiAgICB9LAogICAgImNvbnRlbnRfa2V5X3VzYWdlX3BvbGljaWVzIjogWwogICAgICB7CiAgICAgICAgIm5hbWUiOiAiUG9saWN5IEEiLAogICAgICAgICJwbGF5cmVhZHkiOiB7CiAgICAgICAgICAibWluX2RldmljZV9zZWN1cml0eV9sZXZlbCI6IDE1MCwKICAgICAgICAgICJwbGF5X2VuYWJsZXJzIjogWwogICAgICAgICAgICAiNzg2NjI3RDgtQzJBNi00NEJFLThGODgtMDhBRTI1NUIwMUE3IgogICAgICAgICAgXQogICAgICAgIH0KICAgICAgfQogICAgXQogIH0KfQ._NfhLVY7S6k8TJDWPeMPhUawhympnrk6WAZHOVjER6M';

const sources = {
// HLS with AES-128 encryption: no extra configuration is needed.
Expand All @@ -59,35 +59,28 @@
poster: 'https://cdn.theoplayer.com/video/big_buck_bunny/poster.jpg',
metadata: { title: 'Big Buck Bunny (AES-128)' },
},
// The player picks the first source that is supported by the current browser:
// DASH with Widevine or PlayReady, or HLS with FairPlay.
// A single HLS (CMAF) stream protected with Widevine, PlayReady and FairPlay.
// The player uses the key system that is supported by the current browser.
drm: {
sources: [
{
src: 'https://d2jl6e4h8300i8.cloudfront.net/netflix_meridian/4k-18.5!9/keyos-logo/g180-avc_a2.0-vbr-aac-128k/r30/dash-wv-pr/stream.mpd',
type: 'application/dash+xml',
contentProtection: {
integration: 'keyos',
widevine: {},
playready: {},
preferredKeySystems: ['widevine', 'playready'],
customdata: keyosCustomData,
sources: {
src: 'https://media.axprod.net/TestVectors/Cmaf/protected_1080p_h264_cbcs/manifest.m3u8',
type: 'application/x-mpegurl',
contentProtection: {
integration: 'axinom',
token: axinomToken,
widevine: {
licenseAcquisitionURL: 'https://drm-widevine-licensing.axtest.net/AcquireLicense',
},
},
{
src: 'https://d2jl6e4h8300i8.cloudfront.net/netflix_meridian/4k-19.5!9/keyos-logo/g180-avc_a2.0-vbr-aac-128k/r30/hls-fp/master.m3u8',
type: 'application/x-mpegurl',
contentProtection: {
integration: 'keyos',
fairplay: {
certificateURL: 'https://fp-keyos.licensekeyserver.com/cert/7e11400c7dccd29d0174c674397d99dd.der',
licenseAcquisitionURL: 'https://fp-keyos.licensekeyserver.com/getkey/',
},
customdata: keyosCustomData,
playready: {
licenseAcquisitionURL: 'https://drm-playready-licensing.axtest.net/AcquireLicense',
},
fairplay: {
licenseAcquisitionURL: 'https://drm-fairplay-licensing.axtest.net/AcquireLicense',
certificateURL: 'https://vtb.axinom.com/FPScert/fairplay.cer',
},
},
],
metadata: { title: 'Meridian (Widevine, PlayReady or FairPlay)' },
},
metadata: { title: 'Axinom test vector (Widevine, PlayReady or FairPlay)' },
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Feature modules</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet" />
<style>
html,
body {
margin: 0;
padding: 0;
}

theoplayer-default-ui:not(:defined) {
display: inline-block;
box-sizing: border-box;
}

theoplayer-default-ui {
width: 100%;
aspect-ratio: 16 / 9;
font-family: 'Noto Sans', sans-serif;
background: #000;
}
</style>
<!--
The feature modules are only available as ES modules, so this example loads THEOplayer and Open Video UI as ES modules.
The import map tells the browser where to find each package.
Open Video UI imports the player from "theoplayer/chromeless", so that name points to "theoplayer/core" as well:
the player then only has the features that are imported below.
Comment on lines +32 to +33

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to fix this in Open Video UI too, but that will probably need a major bump. For now, this'll work just fine. 👍

For production use, install the packages from npm and bundle them with your application instead.
-->
<script type="importmap">
{
"imports": {
"theoplayer/core": "https://cdn.theoplayer.com/dash/theoplayer/module/core.js",
"theoplayer/chromeless": "https://cdn.theoplayer.com/dash/theoplayer/module/core.js",
"theoplayer/hls": "https://cdn.theoplayer.com/dash/theoplayer/module/hls.js",
"@theoplayer/web-ui": "https://unpkg.com/@theoplayer/web-ui@2/dist/THEOplayerUI.mjs",
"lit": "https://ga.jspm.io/npm:lit@3.3.2/index.js",
"lit/decorators.js": "https://ga.jspm.io/npm:lit@3.3.2/decorators.js",
"lit/directives/": "https://ga.jspm.io/npm:lit@3.3.2/directives/"
},
"scopes": {
"https://ga.jspm.io/": {
"@lit/reactive-element": "https://ga.jspm.io/npm:@lit/reactive-element@2.1.2/reactive-element.js",
"@lit/reactive-element/decorators/": "https://ga.jspm.io/npm:@lit/reactive-element@2.1.2/decorators/",
"lit-element/lit-element.js": "https://ga.jspm.io/npm:lit-element@4.2.2/lit-element.js",
"lit-html": "https://ga.jspm.io/npm:lit-html@3.3.2/lit-html.js",
"lit-html/": "https://ga.jspm.io/npm:lit-html@3.3.2/"
}
}
}
</script>
<script type="module">
// Import the player without any features, then only the features this page needs.
// Import every feature module before the player is created.
import * as THEOplayer from 'theoplayer/core';
import 'theoplayer/hls';
import '@theoplayer/web-ui';

// Expose the player library for use from the browser's developer console.
window.THEOplayer = THEOplayer;

sendToParent('feature-modules', {
modules: ['theoplayer/core', 'theoplayer/hls'],
features: THEOplayer.features,
version: THEOplayer.version,
});
</script>
</head>
<body>
<!--
libraryLocation: For demonstration purposes, we use the THEOplayer CDN.
For production use, host the library yourself and update this URL and the import map above.

licenseUrl: Change this to point to your THEOplayer license file.
Alternatively, replace it with a "license" property whose value is your THEOplayer license itself.
-->
<theoplayer-default-ui
configuration='{"libraryLocation":"https://cdn.theoplayer.com/dash/theoplayer/","licenseUrl":"../../../../theoplayer-license.txt"}'
source='{"sources":{"src":"https://cdn.theoplayer.com/video/big_buck_bunny/big_buck_bunny_metadata.m3u8","type":"application/x-mpegurl"},"poster":"https://cdn.theoplayer.com/video/big_buck_bunny/poster.jpg","metadata":{"title":"Big Buck Bunny"}}'
></theoplayer-default-ui>
<script src="../utils.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<script nomodule src="https://unpkg.com/@theoplayer/web-ui@2/polyfills"></script>
<script nomodule src="https://unpkg.com/@theoplayer/web-ui@2"></script>
<!-- The Yospace connector. For production use, install @theoplayer/yospace-connector-web from npm. -->
<script src="https://unpkg.com/@theoplayer/yospace-connector-web@3.0.0/dist/yospace-connector.umd.js"></script>
<script src="https://unpkg.com/@theoplayer/yospace-connector-web@3/dist/yospace-connector.umd.js"></script>
</head>
<body>
<!--
Expand Down