Repository navigation
Fix the DRM example, add a feature modules example, and stop pinning package versions in other examples #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1620f69
Replace the expired DRM stream in the DRM example with an Axinom test…
ceyhun-o 8c9c80c
Add a feature modules example for the Web SDK
devin-ai-integration[bot] 1f611ac
Load Open Video UI @2 from unpkg in the feature modules example
devin-ai-integration[bot] b516fb7
Load THEOplayer and Open Video UI from unpkg in the debug display exa…
devin-ai-integration[bot] e3caa72
Load THEOplayer from the CDN again in the debug display example
devin-ai-integration[bot] a63ad74
Load THEOplayer from the CDN in the feature modules example
devin-ai-integration[bot] 3f22421
Load the Conviva and Yospace connectors @3 from unpkg in their examples
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
theoplayer/examples/getting-started/02-feature-modules.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
theoplayer/static/theoplayer/v11/examples/feature-modules/demo.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
| 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> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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. 👍