@theoplayer/react-ui 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE.md +21 -0
- package/README.md +123 -0
- package/dist/THEOplayerReactUI.d.ts +684 -0
- package/dist/THEOplayerReactUI.es5.js +8 -0
- package/dist/THEOplayerReactUI.es5.mjs +5 -0
- package/dist/THEOplayerReactUI.js +5 -0
- package/dist/THEOplayerReactUI.js.map +1 -0
- package/dist/THEOplayerReactUI.mjs +2 -0
- package/dist/THEOplayerReactUI.mjs.map +1 -0
- package/package.json +84 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
> **Tags:**
|
|
4
|
+
>
|
|
5
|
+
> - 💥 Breaking Change
|
|
6
|
+
> - 🚀 New Feature
|
|
7
|
+
> - 🐛 Bug Fix
|
|
8
|
+
> - 👎 Deprecation
|
|
9
|
+
> - 📝 Documentation
|
|
10
|
+
> - 🏠 Internal
|
|
11
|
+
> - 💅 Polish
|
|
12
|
+
|
|
13
|
+
## v1.6.0 (2024-02-08)
|
|
14
|
+
|
|
15
|
+
- 🚀 Initial release
|
|
16
|
+
- 🏠 See changes to [Open Video UI for Web v1.6.0](https://github.com/THEOplayer/web-ui/blob/v1.6.0/CHANGELOG.md)
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 THEO Technologies
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# THEOplayer Open Video UI for React ⚛️
|
|
2
|
+
|
|
3
|
+
A [React](https://react.dev/) component library for building a world-class video player experience powered by
|
|
4
|
+
the [THEOplayer Web SDK](https://www.theoplayer.com/product/theoplayer).
|
|
5
|
+
|
|
6
|
+
- Use the default UI for a great out-of-the-box experience, or use the individual components to build your own custom UI.
|
|
7
|
+
- Idiomatic React components make the UI feel right at home in your existing React web app.
|
|
8
|
+
- Easy to customize: use JSX to lay out your controls, and CSS to style them.
|
|
9
|
+
|
|
10
|
+
> [!NOTE]
|
|
11
|
+
> This project is under active development. While we believe it's ready for use in production, not all features are available in this first release. If you find a problem or have an idea for a new feature, don't hesitate to [open an issue](https://github.com/THEOplayer/web-ui/issues)!
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
1. This project requires the THEOplayer Web SDK to be installed.
|
|
16
|
+
```sh
|
|
17
|
+
npm install theoplayer
|
|
18
|
+
```
|
|
19
|
+
You can also install a different variant of the THEOplayer npm package if you don't need all features, as long as it's aliased as `theoplayer`.
|
|
20
|
+
```sh
|
|
21
|
+
npm install theoplayer@npm:@theoplayer/basic-hls
|
|
22
|
+
```
|
|
23
|
+
2. Install the Open Video UI for React.
|
|
24
|
+
```sh
|
|
25
|
+
npm install @theoplayer/react-ui
|
|
26
|
+
```
|
|
27
|
+
3. Add `@theoplayer/react-ui` to your app:
|
|
28
|
+
```jsx
|
|
29
|
+
import { DefaultUI } from '@theoplayer/react-ui';
|
|
30
|
+
```
|
|
31
|
+
Open Video UI will import THEOplayer from `theoplayer/chromeless`.
|
|
32
|
+
If you're using a bundler such as Webpack or Rollup, this dependency should automatically get bundled with your web app.
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Default UI
|
|
37
|
+
|
|
38
|
+
`<DefaultUI>` provides a fully-featured video player experience with minimal setup, and allows for small customizations such as changing colors or fonts.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { DefaultUI } from '@theoplayer/react-ui';
|
|
42
|
+
import type { ChromelessPlayer } from 'theoplayer/chromeless';
|
|
43
|
+
|
|
44
|
+
const App = () => {
|
|
45
|
+
// Configure THEOplayer
|
|
46
|
+
const configuration = {
|
|
47
|
+
libraryLocation: '/path/to/node_modules/theoplayer/',
|
|
48
|
+
license: 'your_theoplayer_license_goes_here'
|
|
49
|
+
};
|
|
50
|
+
// Configure a source for the player to play
|
|
51
|
+
const source = {
|
|
52
|
+
sources: {
|
|
53
|
+
src: 'https://example.com/stream.m3u8'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// Optionally, access the underlying THEOplayer player instance
|
|
57
|
+
const onReady = (player: ChromelessPlayer) => {
|
|
58
|
+
player.addEventListener('playing', () => console.log('THEOplayer is now playing'));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return <DefaultUI configuration={configuration} source={source} onReady={onReady} />;
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
See [docs/examples/react.html](https://github.com/THEOplayer/web-ui/blob/main/docs/examples/react.html) for a complete example.
|
|
66
|
+
|
|
67
|
+
### Custom UI
|
|
68
|
+
|
|
69
|
+
If you want to fully customize your video player layout, you can use a `<UIContainer>` instead.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { ControlBar, MuteButton, PlayButton, TimeRange, VolumeRange } from '@theoplayer/react-ui';
|
|
73
|
+
|
|
74
|
+
const App = () => {
|
|
75
|
+
const configuration = {
|
|
76
|
+
libraryLocation: '/path/to/node_modules/theoplayer/',
|
|
77
|
+
license: 'your_theoplayer_license_goes_here'
|
|
78
|
+
};
|
|
79
|
+
const source = {
|
|
80
|
+
sources: {
|
|
81
|
+
src: 'https://example.com/stream.m3u8'
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<UIContainer
|
|
87
|
+
configuration={configuration}
|
|
88
|
+
source={source}
|
|
89
|
+
bottomChrome={
|
|
90
|
+
<>
|
|
91
|
+
{/* Choose your own layout using the provided components (or your own!) */}
|
|
92
|
+
<ControlBar>
|
|
93
|
+
<TimeRange />
|
|
94
|
+
</ControlBar>
|
|
95
|
+
<ControlBar>
|
|
96
|
+
<PlayButton />
|
|
97
|
+
<MuteButton />
|
|
98
|
+
<VolumeRange />
|
|
99
|
+
</ControlBar>
|
|
100
|
+
</>
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
See [docs/examples/react.html](https://github.com/THEOplayer/web-ui/blob/main/docs/examples/react.html) for a complete example.
|
|
108
|
+
|
|
109
|
+
# Legacy browser support
|
|
110
|
+
|
|
111
|
+
By default, Open Video UI for React targets modern browsers that support modern JavaScript syntax (such as [async/await](https://caniuse.com/async-functions)) and native [Custom Elements](https://caniuse.com/custom-elementsv1). This keeps the download size small, so your viewers can spend less time waiting for your page to load and start watching their video faster.
|
|
112
|
+
|
|
113
|
+
On older browsers (such as Internet Explorer 11 and older smart TVs), you need to load a different version of the Open Video UI that uses older JavaScript syntax. You also need to load additional polyfills for missing features such as Promises or Custom Elements. We recommend [Polyfill.io](https://polyfill.io/) and [Web Components Polyfills](https://github.com/webcomponents/polyfills) for these.
|
|
114
|
+
|
|
115
|
+
The simplest way to do this is to load the legacy build instead:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js';
|
|
119
|
+
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
|
|
120
|
+
import { DefaultUI } from '@theoplayer/react-ui/es5'; // note the "/es5" suffix
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
However, this will load unnecessary polyfills in modern browsers, which is suboptimal. Instead, we recommend configuring your bundler to produce a modern and legacy build of your entire web app, and to import the appropriate version of Open Video UI for each build flavor.
|