@theoplayer/web-ui 1.0.0 → 1.2.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/README.md +60 -32
- package/dist/THEOplayerUI.d.ts +1658 -1628
- package/dist/THEOplayerUI.es5.js +4 -0
- package/dist/THEOplayerUI.es5.mjs +1 -0
- package/dist/THEOplayerUI.js +33 -2
- package/dist/THEOplayerUI.js.map +1 -1
- package/dist/THEOplayerUI.mjs +15 -1
- package/dist/THEOplayerUI.mjs.map +1 -1
- package/package.json +18 -7
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ the [THEOplayer Web SDK](https://www.theoplayer.com/product/theoplayer).
|
|
|
10
10
|
> **Note**
|
|
11
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
12
|
|
|
13
|
-
|  |  |
|
|
14
|
+
| :---------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: |
|
|
15
|
+
| Desktop | Mobile |
|
|
16
16
|
|
|
17
17
|
## Motivation
|
|
18
18
|
|
|
@@ -27,29 +27,27 @@ The current THEOplayer Web SDK comes with a built-in UI based on [video.js](http
|
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
30
|
-
This project requires the THEOplayer Web SDK to be installed.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
npm install theoplayer @theoplayer/web-ui
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
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`.
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
npm install theoplayer@npm:@theoplayer/basic-hls
|
|
40
|
-
npm install @theoplayer/web-ui
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Then add `@theoplayer/web-ui` to your app:
|
|
44
|
-
|
|
45
|
-
- Option 1: in your HTML.
|
|
46
|
-
```html
|
|
47
|
-
<script src="/path/to/node_modules/@theoplayer/web-ui/dist/THEOplayerUI.js"></script>
|
|
30
|
+
1. This project requires the THEOplayer Web SDK to be installed.
|
|
31
|
+
```sh
|
|
32
|
+
npm install theoplayer
|
|
48
33
|
```
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
|
|
34
|
+
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`.
|
|
35
|
+
```sh
|
|
36
|
+
npm install theoplayer@npm:@theoplayer/basic-hls
|
|
37
|
+
```
|
|
38
|
+
2. Install the THEOplayer Web UI.
|
|
39
|
+
```sh
|
|
40
|
+
npm install @theoplayer/web-ui
|
|
52
41
|
```
|
|
42
|
+
3. Add `@theoplayer/web-ui` to your app:
|
|
43
|
+
- Option 1: in your HTML.
|
|
44
|
+
```html
|
|
45
|
+
<script src="/path/to/node_modules/@theoplayer/web-ui/dist/THEOplayerUI.js"></script>
|
|
46
|
+
```
|
|
47
|
+
- Option 2: in your JavaScript.
|
|
48
|
+
```js
|
|
49
|
+
import { DefaultUI } from '@theoplayer/web-ui';
|
|
50
|
+
```
|
|
53
51
|
|
|
54
52
|
> **Warning**
|
|
55
53
|
> THEOplayer Web SDK currently only supports being loaded through a regular `<script>` tag or as a [UMD module](https://github.com/umdjs/umd), and does not support being `import`ed as a native JavaScript module. If you use `import` with THEOplayer Web UI, make sure to use a JavaScript bundler such as Webpack or Rollup to include THEOplayer in your app. We're hoping to fix this incompatibility soon.
|
|
@@ -66,25 +64,30 @@ Then add `@theoplayer/web-ui` to your app:
|
|
|
66
64
|
configuration='{"libraryLocation":"/path/to/node_modules/theoplayer/","license":"your_theoplayer_license_goes_here"}'
|
|
67
65
|
source='{"sources":{"src":"https://example.com/stream.m3u8"}}'
|
|
68
66
|
></theoplayer-default-ui>
|
|
67
|
+
<script>
|
|
68
|
+
// Optionally, access the underlying THEOplayer player instance
|
|
69
|
+
const ui = document.querySelector('theoplayer-default-ui');
|
|
70
|
+
ui.player.addEventListener('playing', () => console.log('THEOplayer is now playing'));
|
|
71
|
+
</script>
|
|
69
72
|
```
|
|
70
73
|
- Option 2: in your JavaScript.
|
|
71
74
|
```js
|
|
72
75
|
import { DefaultUI } from '@theoplayer/web-ui';
|
|
73
76
|
const ui = new DefaultUI({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
license: 'your_theoplayer_license_goes_here'
|
|
77
|
-
}
|
|
77
|
+
libraryLocation: '/path/to/node_modules/theoplayer/',
|
|
78
|
+
license: 'your_theoplayer_license_goes_here'
|
|
78
79
|
});
|
|
80
|
+
// Set a source for the player to play
|
|
79
81
|
ui.source = {
|
|
80
82
|
sources: {
|
|
81
83
|
src: 'https://example.com/stream.m3u8'
|
|
82
84
|
}
|
|
83
85
|
};
|
|
86
|
+
// Optionally, access the underlying THEOplayer player instance
|
|
87
|
+
ui.player.addEventListener('playing', () => console.log('THEOplayer is now playing'));
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
See [docs/examples/default-ui.html](https://github.com/THEOplayer/web-ui/blob/main/docs/examples/default-ui.html) for a complete
|
|
87
|
-
example.
|
|
90
|
+
See [docs/examples/default-ui.html](https://github.com/THEOplayer/web-ui/blob/main/docs/examples/default-ui.html) for a complete example.
|
|
88
91
|
|
|
89
92
|
### Custom UI
|
|
90
93
|
|
|
@@ -107,5 +110,30 @@ If you want to fully customize your video player layout, you can use a `<theopla
|
|
|
107
110
|
</theoplayer-ui>
|
|
108
111
|
```
|
|
109
112
|
|
|
110
|
-
See [docs/examples/custom-ui.html](https://github.com/THEOplayer/web-ui/blob/main/docs/examples/custom-ui.html) for a complete
|
|
111
|
-
|
|
113
|
+
See [docs/examples/custom-ui.html](https://github.com/THEOplayer/web-ui/blob/main/docs/examples/custom-ui.html) for a complete example.
|
|
114
|
+
|
|
115
|
+
# Legacy browser support
|
|
116
|
+
|
|
117
|
+
By default, THEOplayer Web UI 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.
|
|
118
|
+
|
|
119
|
+
On older browsers (such as Internet Explorer 11 and older smart TVs), you need to load a different version of the THEOplayer Web 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.
|
|
120
|
+
|
|
121
|
+
- Option 1: in your HTML. This uses [differential serving](https://css-tricks.com/differential-serving/) so modern browsers will load the modern build (with `type="module"`, while legacy browsers will load the legacy build (with `nomodule`).
|
|
122
|
+
|
|
123
|
+
```html
|
|
124
|
+
<!-- Load polyfills -->
|
|
125
|
+
<script nomodule src="https://polyfill.io/v3/polyfill.min.js?features=es2015"></script>
|
|
126
|
+
<script nomodule src="https://unpkg.com/@webcomponents/webcomponentsjs@2.8.0/custom-elements-es5-adapter.js"></script>
|
|
127
|
+
<script nomodule src="https://unpkg.com/@webcomponents/webcomponentsjs@2.8.0/webcomponents-bundle.js"></script>
|
|
128
|
+
<!-- Load modern or legacy build -->
|
|
129
|
+
<script type="module" src="/path/to/node_modules/@theoplayer/web-ui/dist/THEOplayerUI.js"></script>
|
|
130
|
+
<script nomodule src="/path/to/node_modules/@theoplayer/web-ui/dist/THEOplayerUI.es5.js"></script>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- Option 2: in your JavaScript. This will load the legacy build on both modern and legacy 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 THEOplayer Web UI for each build flavor.
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js';
|
|
137
|
+
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
|
|
138
|
+
import { DefaultUI } from '@theoplayer/web-ui/es5'; // note the "/es5" suffix
|
|
139
|
+
```
|