@vidispine/vdt-videojs 21.3.0 → 22.1.0-pre.1

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.
Files changed (55) hide show
  1. package/README.md +4 -4
  2. package/deprecated-app/README.md +21 -0
  3. package/{demo.html → deprecated-app/index.html} +1 -1
  4. package/{demo.js → deprecated-app/index.js} +69 -41
  5. package/{samples → deprecated-app/samples}/birds-es.vvt +0 -0
  6. package/{samples → deprecated-app/samples}/birds.vvt +0 -0
  7. package/{tests.js → deprecated-app/tests.js} +87 -54
  8. package/{lib/style.css → dist/index.css} +755 -55
  9. package/dist/index.es.js +2099 -0
  10. package/dist/index.js +2112 -0
  11. package/dist/index.umd.js +2115 -0
  12. package/package.json +29 -85
  13. package/rollup.config.js +54 -0
  14. package/src/constants.js +1 -1
  15. package/src/externalControls.js +14 -18
  16. package/src/helpOverlay.js +12 -16
  17. package/src/helpers.js +3 -3
  18. package/src/index.js +3 -9
  19. package/src/index.stories.mdx +59 -0
  20. package/src/menu.api.stories.mdx +59 -0
  21. package/src/menu.js +23 -19
  22. package/src/{menu.example.md → menu.usage.stories.mdx} +31 -21
  23. package/src/osd.js +24 -18
  24. package/src/player.api.stories.mdx +120 -0
  25. package/src/player.js +157 -108
  26. package/src/player.scss +2 -0
  27. package/src/{player.example.md → player.usage.stories.mdx} +18 -8
  28. package/src/seekBar.js +85 -48
  29. package/src/timeCodeDisplay.js +39 -31
  30. package/src/videoTime.js +4 -4
  31. package/build.js +0 -233
  32. package/lib/index.cjs.js +0 -3240
  33. package/lib/index.esm.js +0 -3227
  34. package/lib/index.umd.js +0 -3243
  35. package/lib/package.json +0 -13
  36. package/lib/src/constants.js +0 -51
  37. package/lib/src/externalControls.js +0 -307
  38. package/lib/src/helpOverlay.js +0 -106
  39. package/lib/src/helpers.js +0 -34
  40. package/lib/src/index.js +0 -13
  41. package/lib/src/menu.js +0 -365
  42. package/lib/src/osd.js +0 -91
  43. package/lib/src/player.js +0 -943
  44. package/lib/src/seekBar.js +0 -833
  45. package/lib/src/timeCodeDisplay.js +0 -253
  46. package/lib/src/videoTime.js +0 -66
  47. package/log.js +0 -24
  48. package/src/_index.stories.js +0 -24
  49. package/src/externalControls.stories.js +0 -6
  50. package/src/helpOverlay.stories.js +0 -6
  51. package/src/menu.classMethods.md +0 -47
  52. package/src/player.classMethods.md +0 -108
  53. package/src/player.stories.js +0 -14
  54. package/src/seekBar.stories.js +0 -8
  55. package/tmp/player.css +0 -1
package/lib/package.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "name": "@vidispine/vdt-videojs",
3
- "version": "21.3.0",
4
- "license": "UNLICENSED",
5
- "author": "Oto Inša <otoinsa@bertelsmann.de>",
6
- "dependencies": {
7
- "mousetrap": "^1.6.3",
8
- "video.js": "^7.6.6"
9
- },
10
- "private": false,
11
- "main": "index.cjs.js",
12
- "module": "index.esm.js"
13
- }
@@ -1,51 +0,0 @@
1
- import pkgInfo from '../package.json';
2
-
3
- export const defaults = Object.freeze({
4
- frameRate: (30000 / 1001),
5
- jumpSeconds: 10,
6
- inactivityTimeout: 1200,
7
- audioInactivityTimeout: 0,
8
- });
9
-
10
- export const osd = Object.freeze({
11
- play: 0,
12
- pause: 1,
13
- volchange: 2,
14
- jumpForward: 3,
15
- jumpBackward: 4,
16
- });
17
-
18
- export const settings = Object.freeze({
19
- volume: 'volume-setting',
20
- subLang: 'subtitles-language',
21
- subs: 'subtitles-enabled',
22
- });
23
-
24
- export const classNames = Object.freeze({
25
- poster: 'has-poster',
26
- subtitles: 'has-subtitles',
27
- subtitlesActive: 'subtitles-active',
28
- onDark: 'on-dark',
29
- loading: 'loading',
30
- });
31
-
32
- export const colors = Object.freeze({
33
- gray: '#787878',
34
- light: 'rgba(255,255,255,.75)',
35
- });
36
-
37
- export const packageInfo = Object.freeze({
38
- name: pkgInfo.name.split('/')[1],
39
- vendor: pkgInfo.name.split('/')[0],
40
- });
41
-
42
- const constants = Object.freeze({
43
- defaults,
44
- settings,
45
- classNames,
46
- colors,
47
- osd,
48
- packageInfo,
49
- });
50
-
51
- export default constants;
@@ -1,307 +0,0 @@
1
- import { reactiveSetters } from './helpers';
2
- import { classNames, colors } from './constants';
3
-
4
- const buttonNames = Object.freeze({
5
- play: 'play-pause',
6
- start: 'start',
7
- fb: 'frame-backward',
8
- ff: 'frame-forward',
9
- end: 'end',
10
- });
11
-
12
- const buttons = [
13
- buttonNames.start,
14
- buttonNames.fb,
15
- buttonNames.play,
16
- buttonNames.ff,
17
- buttonNames.end,
18
- ];
19
-
20
-
21
- const CSS = `
22
- .vdt-external-controls{
23
- display: flex;
24
- justify-content: center;
25
- align-items: center;
26
- }
27
-
28
- .control{
29
- flex: 1;
30
- flex-grow: 1;
31
- height: 100%;
32
- align-contents: center;
33
- align-self: center;
34
- text-align: center;
35
- vertical-align: middle;
36
- cursor: pointer;
37
- user-select: none;
38
- height: 20px;
39
- padding-top: 10px;
40
- padding-bottom: 10px;
41
- }
42
-
43
- .control .icon{
44
- display: inline-block;
45
- height: 20px;
46
- white-space: nowrap;
47
- opacity: .9;
48
- }
49
-
50
- .control:hover .icon{ opacity: 1; }
51
-
52
- .control .icon:before{
53
- opacity: 1;
54
- flex: 1;
55
- align-self: center;
56
- content: " ";
57
- display: inline-block;
58
- margin: 0 auto;
59
-
60
- /* triangles */
61
- width: 0;
62
- height: 0;
63
- border-style: solid;
64
- border-width: 16px 0 16px 23px;
65
- border-color: transparent transparent transparent ${colors.gray};
66
- }
67
-
68
- .vdt-external-controls.${classNames.onDark} .control .icon:before{
69
- border-color: transparent transparent transparent ${colors.light};
70
- }
71
-
72
- /* specific buttons */
73
-
74
- .control.${buttonNames.start},
75
- .control.${buttonNames.end}{
76
- height: 20px;
77
- }
78
-
79
- .control.${buttonNames.play}{
80
- height: 30px;
81
- padding-top: 0px;
82
- padding-bottom: 0px;
83
- }
84
-
85
- .control.${buttonNames.play} .icon{
86
- height: 30px;
87
- }
88
-
89
- .control.${buttonNames.ff} .icon:before,
90
- .control.${buttonNames.fb} .icon:before,
91
- .control.${buttonNames.end} .icon:before,
92
- .control.${buttonNames.start} .icon:before{
93
- border-width: 10px 0 10px 16px;
94
- }
95
-
96
- .control.${buttonNames.fb} .icon,
97
- .control.${buttonNames.start}{
98
- transform: rotate(180deg);
99
- }
100
-
101
- .control.${buttonNames.end} .icon:after,
102
- .control.${buttonNames.start} .icon:after{
103
- content: " ";
104
- width: 4px;
105
- height: 20px;
106
- display: inline-block;
107
- background: ${colors.gray};
108
- }
109
-
110
- .vdt-external-controls.${classNames.onDark} .control.${buttonNames.end} .icon:after,
111
- .vdt-external-controls.${classNames.onDark} .control.${buttonNames.start} .icon:after{
112
- background: ${colors.light};
113
- }
114
-
115
- /* stateful styles */
116
- .control.${buttonNames.play}.playing .icon:before{
117
- height: 30px;
118
- width: 6px;
119
- border-width: 0px 8px 0px 8px;
120
- border-color: transparent ${colors.gray} transparent ${colors.gray};
121
- }
122
-
123
- .vdt-external-controls.${classNames.onDark} .control.${buttonNames.play}.playing .icon:before{
124
- border-color: transparent ${colors.light} transparent ${colors.light};
125
- }
126
-
127
- .vdt-external-controls.${classNames.loading} .control.${buttonNames.play}{
128
- border-color: transparent #f00 transparent #f00;
129
- }
130
- `;
131
-
132
- class ExternalControls {
133
- constructor(props) {
134
- this.props = props;
135
- reactiveSetters.apply(this);
136
-
137
- this.state = {
138
- playing: false,
139
- onDark: false,
140
- loading: false,
141
- };
142
-
143
- this.shadowRoot = document.createElement('div');
144
- this.shadowRoot.className = 'vdt-external-controls-wrapper';
145
- this.container = document.createElement('div');
146
- this.container.className = 'vdt-external-controls';
147
-
148
- if (this.props.target) {
149
- this.props.target.appendChild(this.shadowRoot);
150
- this.shadow = this.shadowRoot.attachShadow({ mode: 'open' });
151
-
152
- this.style = document.createElement('style');
153
- this.style.type = 'text/css';
154
- this.style.appendChild(document.createTextNode(CSS));
155
- this.shadow.appendChild(this.style);
156
-
157
-
158
- this.shadow.appendChild(this.container);
159
- }
160
-
161
- this.handleNewProps(props);
162
- this.bindEvents();
163
- this.draw();
164
- }
165
-
166
- draw() {
167
- this.buttons = {};
168
- const excludes = this.props.excludes || [];
169
-
170
- buttons.forEach((buttonName) => {
171
- if (excludes.indexOf(buttonName) < 0) {
172
- const btn = document.createElement('div');
173
- btn.className = `control ${buttonName}`;
174
- btn.innerHTML = '<span class="icon"></span>';
175
-
176
- btn.onclick = () => {
177
- this.handlePress(buttonName);
178
- };
179
-
180
- this.buttons[buttonName] = btn;
181
- this.container.appendChild(btn);
182
- }
183
- });
184
- }
185
-
186
- bindEvents() {
187
- if (this.props.player && this.props.player.videojs) {
188
- const { player } = this.props;
189
-
190
- player.videojs.on('play', () => {
191
- this.playing = true;
192
- });
193
-
194
- player.videojs.on('pause', () => {
195
- this.playing = false;
196
- });
197
-
198
- player.videojs.on('stop', () => {
199
- this.playing = false;
200
- });
201
- }
202
- }
203
-
204
- handlePress(buttonName) {
205
- if (this.props.player) {
206
- const player = this.props.player;
207
- console.log(player)
208
- player.osd && player.osd.disable();
209
-
210
- switch (buttonName) {
211
- case buttonNames.start:
212
- player.toStart();
213
- break;
214
- case buttonNames.fb:
215
- player.triggerHotkey('left');
216
- break;
217
- case buttonNames.play:
218
- player.triggerHotkey('k');
219
- break;
220
- case buttonNames.ff:
221
- player.triggerHotkey('right');
222
- break;
223
- case buttonNames.end:
224
- player.toEnd();
225
- break;
226
- default:
227
-
228
- break;
229
- }
230
-
231
- player.osd && player.osd.enable();
232
- } else {
233
- switch (buttonName) {
234
- case buttonNames.start:
235
- this.props.onPrev && this.props.onPrev();
236
- break;
237
- case buttonNames.fb:
238
- this.props.onFB && this.props.onFB();
239
- break;
240
- case buttonNames.play:
241
- if (this.playing) {
242
- this.props.onPause && this.props.onPause();
243
- } else {
244
- this.props.onPlay && this.props.onPlay();
245
- }
246
- break;
247
- case buttonNames.ff:
248
- this.props.onFF && this.props.onFF();
249
- break;
250
- case buttonNames.end:
251
- this.props.onNext && this.props.onNext();
252
- break;
253
- default:
254
-
255
- break;
256
- }
257
- }
258
- }
259
-
260
-
261
- set playing(bool) {
262
- if (bool) {
263
- this.state.playing = true;
264
- this.buttons[buttonNames.play].classList.add('playing');
265
- } else {
266
- this.state.playing = false;
267
- this.buttons[buttonNames.play].classList.remove('playing');
268
- }
269
- }
270
-
271
- get playing() {
272
- return this.state.playing;
273
- }
274
-
275
- set onDark(bool) {
276
- if (bool) {
277
- this.state.onDark = true;
278
- this.container.classList.add(classNames.onDark);
279
- } else {
280
- this.state.onDark = false;
281
- this.container.classList.remove(classNames.onDark);
282
- }
283
- }
284
-
285
- get onDark() {
286
- return this.container.classList.contains(classNames.onDark);
287
- }
288
-
289
- set loading(bool) {
290
- if (bool) {
291
- this.state.loading = true;
292
- this.container.classList.add(classNames.loading);
293
- } else {
294
- this.state.loading = false;
295
- this.container.classList.remove(classNames.loading);
296
- }
297
- }
298
-
299
- get loading() {
300
- return this.state.loading;
301
- }
302
- }
303
-
304
- ExternalControls.buttonNames = buttonNames;
305
-
306
-
307
- export default ExternalControls;
@@ -1,106 +0,0 @@
1
-
2
- import mousetrap from 'mousetrap';
3
-
4
- export default class HelpOverlay {
5
- constructor(props) {
6
- this.props = props;
7
-
8
- this.state = {
9
- active: this.props.active || false,
10
- };
11
-
12
- this.container = document.createElement('div');
13
- this.container.className = 'vdt-help-overlay';
14
- this.container.innerHTML = '';
15
- this.container.onclick = () => {
16
- this.hide();
17
- };
18
-
19
- this.props.target && this.props.target.appendChild(this.container);
20
-
21
- this.draw();
22
- }
23
-
24
- draw() { // draws keyboard controls
25
- let tableRowMarkup = ''; // will insert a DOM string here
26
- const rows = [
27
- ['⎵', 'Play / Pause'],
28
- ['⇧', 'Increase volume '],
29
- ['⇩', 'Decrease volume'],
30
- ['⇨', 'Step frame forward'],
31
- ['⇦', 'Step frame backward'],
32
- ['M', 'Mute / Unmute'],
33
-
34
- ['J', 'Seek 10 seconds backward'],
35
- ['K', 'Play / Pause'],
36
- ['L', 'Seek 10 seconds forward'],
37
- ['C', 'Toggle subtitles'],
38
- ['N', 'Toggle settings menu'],
39
- ['H', 'Toggle this help overlay'],
40
- ];
41
-
42
-
43
-
44
- const halfpointIndex = Math.round(rows.length / 2);
45
- const columns = [
46
- rows.slice(0, halfpointIndex),
47
- rows.slice(halfpointIndex, rows.length),
48
- ];
49
-
50
-
51
- for (let i = 0; i < halfpointIndex; i++) {
52
- tableRowMarkup += `
53
- <tr>
54
- <td><div>${columns[0][i][0]}</div></td>
55
- <td>- ${columns[0][i][1]}</td>
56
-
57
- <td>${(columns[1][i]) ? `<div>${columns[1][i][0]}</div>` : ''}</td>
58
- <td>${(columns[1][i]) ? `- ${columns[1][i][1]}` : ''}</td>
59
- </tr>
60
- `;
61
- }
62
-
63
-
64
- this.container.innerHTML = `
65
- <table>
66
- <tbody>
67
- <tr>
68
- <td class="vdt-help-contents">
69
- <table><tbody>${tableRowMarkup}</tbody></table>
70
- </td>
71
- </tr>
72
- </tbody>
73
- </table>
74
- `;
75
- }
76
-
77
- show() {
78
- if (!this.state.active) {
79
- this.container.classList.add('active');
80
- this.state.active = true;
81
-
82
- mousetrap.bind('esc', () => { this.hide(); });
83
-
84
- this.props.onToggle && this.props.onToggle(true);
85
- }
86
- }
87
-
88
- hide() {
89
- if (this.state.active) {
90
- this.container.classList.remove('active');
91
- this.state.active = false;
92
-
93
- mousetrap.unbind('esc');
94
-
95
- this.props.onToggle && this.props.onToggle(false);
96
- }
97
- }
98
-
99
- toggle() {
100
- if (this.state.active) {
101
- this.hide();
102
- } else {
103
- this.show();
104
- }
105
- }
106
- }
@@ -1,34 +0,0 @@
1
- export function truncate(input, len) {
2
- if (input.length > len) return `${input.substring(0, len)}...`;
3
- return input;
4
- }
5
-
6
-
7
- export function reactiveSetters() {
8
-
9
-
10
- function handleNewProps(props) {
11
- if (typeof props === 'object') {
12
- const keys = Object.getOwnPropertyNames(props);
13
- const proto = Object.getPrototypeOf(this);
14
- keys.forEach((key) => {
15
-
16
- const descriptor = Object.getOwnPropertyDescriptor(proto, key);
17
-
18
- if (descriptor && descriptor.set) {
19
- this[key] = props[key];
20
- }
21
- });
22
- }
23
- }
24
-
25
-
26
- this.handleNewProps = handleNewProps;
27
- }
28
-
29
-
30
- export function sanitize(str) {
31
- const temp = document.createElement('div');
32
- temp.textContent = str;
33
- return temp.innerHTML;
34
- }
package/lib/src/index.js DELETED
@@ -1,13 +0,0 @@
1
- import Player from './player';
2
- import TimeCodeDisplay from './timeCodeDisplay';
3
- import ExternalControls from './externalControls';
4
- import SeekBar from './seekBar';
5
- import VideoTime from './videoTime';
6
-
7
- export {
8
- TimeCodeDisplay,
9
- ExternalControls,
10
- SeekBar,
11
- Player,
12
- VideoTime,
13
- };