@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
@@ -1,39 +1,52 @@
1
- # Player Menu API
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta
4
+ title="vdt-videojs/Player Menu/Example Usage"
5
+ parameters={{
6
+ viewMode: 'docs',
7
+ previewTabs: {
8
+ canvas: { hidden: true },
9
+ },
10
+ }}
11
+ />
12
+
13
+ ## Example Usage
2
14
 
3
15
  It's possible to pass your own menu items to a new Player instance during initialization like so:
4
16
 
5
- ```
6
- new Player({
17
+ ```js
18
+ const player = new Player({
7
19
  target,
8
20
  sources: testData[randIndex].sources,
9
21
  menuItems,
10
- ...
11
- })
22
+ // ...
23
+ });
12
24
  ```
13
25
 
14
26
  The items can be defined as follows:
15
27
 
16
- ```
28
+ ```js
17
29
  const menuItems = [
18
30
  {
19
31
  title: 'Example 1',
20
- getActiveIndex: (subitems)=>{ // predicate method for determining active index
21
- let activeIndex = 0
32
+ // predicate method for determining active index
33
+ getActiveIndex: (subitems) => {
34
+ let activeIndex = 0;
22
35
 
23
- subitems.forEach((item, index)=>{
24
- if(item.src === player.src){
25
- activeIndex = index
36
+ subitems.forEach((item, index) => {
37
+ if (item.src === player.src) {
38
+ activeIndex = index;
26
39
  }
27
- })
40
+ });
28
41
 
29
- return activeIndex
42
+ return activeIndex;
30
43
  },
31
44
  items: [
32
45
  {
33
46
  title: 'Option 1',
34
47
  src: '//vjs.zencdn.net/v/oceans.mp4',
35
48
  onClick: (event, item) => {
36
- console.log(event, item, player)
49
+ console.log(event, item, player);
37
50
  },
38
51
  },
39
52
  {
@@ -41,16 +54,13 @@ const menuItems = [
41
54
  src: '//commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4',
42
55
  someKey: 'value', // store arbitrary data
43
56
  onClick: (event, item) => {
44
- console.log(event, item, player)
57
+ console.log(event, item, player);
45
58
  },
46
59
  },
47
- ]
48
- }
49
- ]
50
-
51
-
60
+ ],
61
+ },
62
+ ];
52
63
  ```
53
64
 
54
65
  Note the `getActiveIndex` method on top level items - this method is invoked
55
66
  during opening of the menu, while navigating up to main level and on the first draw to determine the active (selected) item.
56
-
package/src/osd.js CHANGED
@@ -1,8 +1,4 @@
1
- /* eslint-disable prefer-destructuring */
2
- /* eslint-disable no-unused-expressions */
3
- /* eslint-disable no-case-declarations */
4
-
5
- import constants from './constants';
1
+ import { osd } from './constants';
6
2
 
7
3
  export default class OSD {
8
4
  constructor(props) {
@@ -26,12 +22,14 @@ export default class OSD {
26
22
  </table>
27
23
  `;
28
24
 
25
+ // eslint-disable-next-line prefer-destructuring
29
26
  this.iconEl = this.container.getElementsByClassName('osd-feedback-icon')[0];
30
27
 
31
- this.props.target && this.props.target.appendChild(this.container);
28
+ if (this.props.target) this.props.target.appendChild(this.container);
32
29
  }
33
30
 
34
- feedback(feedbackType, details = null) { // details - {} - can contain additional data
31
+ feedback(feedbackType, details = null) {
32
+ // details - {} - can contain additional data
35
33
  if (!this.state.enabled) {
36
34
  return;
37
35
  }
@@ -39,14 +37,16 @@ export default class OSD {
39
37
  let className;
40
38
 
41
39
  switch (feedbackType) {
42
- case constants.osd.pause:
40
+ case osd.pause:
43
41
  className = 'pause';
44
42
  break;
45
- case constants.osd.play:
43
+ case osd.play:
46
44
  className = 'play';
47
45
  break;
48
- case constants.osd.volchange:
46
+ case osd.volchange:
47
+ // eslint-disable-next-line no-case-declarations
49
48
  const currentVolumeLevel = details.volume;
49
+ // eslint-disable-next-line no-case-declarations
50
50
  let perceivedVolumeLevel; // 'low' | 'mid' | 'high' string to utilize video js eisting icons
51
51
 
52
52
  /*
@@ -55,17 +55,23 @@ export default class OSD {
55
55
  so... no case switch inside case switch this time :/
56
56
  */
57
57
 
58
- // alues here are a bit of a guess, but they seem to match videojs thresholds
59
- if (currentVolumeLevel === 0) { perceivedVolumeLevel = 'null'; } else
60
- if (currentVolumeLevel > 0.65) { perceivedVolumeLevel = 'high'; } else
61
- if (currentVolumeLevel < 0.35) { perceivedVolumeLevel = 'low'; } else { perceivedVolumeLevel = 'mid'; }
58
+ // values here are a bit of a guess, but they seem to match videojs thresholds
59
+ if (currentVolumeLevel === 0) {
60
+ perceivedVolumeLevel = 'null';
61
+ } else if (currentVolumeLevel > 0.65) {
62
+ perceivedVolumeLevel = 'high';
63
+ } else if (currentVolumeLevel < 0.35) {
64
+ perceivedVolumeLevel = 'low';
65
+ } else {
66
+ perceivedVolumeLevel = 'mid';
67
+ }
62
68
 
63
69
  className = `volchange ${perceivedVolumeLevel}`;
64
70
  break;
65
- case constants.osd.jumpForward:
71
+ case osd.jumpForward:
66
72
  className = 'forward-jump';
67
73
  break;
68
- case constants.osd.jumpBackward:
74
+ case osd.jumpBackward:
69
75
  className = 'backward-jump';
70
76
  break;
71
77
  default:
@@ -73,8 +79,8 @@ export default class OSD {
73
79
  break;
74
80
  }
75
81
 
76
-
77
- if (this.osdTimeout) { // should clear previous timeout/classname if in progress
82
+ if (this.osdTimeout) {
83
+ // should clear previous timeout/classname if in progress
78
84
  this.container.classList.remove('active');
79
85
  clearTimeout(this.osdTimeout);
80
86
  }
@@ -0,0 +1,120 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta
4
+ title="vdt-videojs/Player/Class Methods"
5
+ parameters={{
6
+ viewMode: 'docs',
7
+ previewTabs: {
8
+ canvas: { hidden: true },
9
+ },
10
+ }}
11
+ />
12
+
13
+ ## Class Methods
14
+
15
+ <table>
16
+ <thead>
17
+ <tr>
18
+ <th>Method</th>
19
+ <th>Description</th>
20
+ <th>Associated hotkey</th>
21
+ </tr>
22
+ </thead>
23
+ <tbody>
24
+ <tr>
25
+ <td>.togglePlayback()</td>
26
+ <td>toggle Play / Pause</td>
27
+ <td>Space, K</td>
28
+ </tr>
29
+ <tr>
30
+ <td>.pause()</td>
31
+ <td>Pause</td>
32
+ <td />
33
+ </tr>
34
+ <tr>
35
+ <td>.play()</td>
36
+ <td>Play</td>
37
+ <td />
38
+ </tr>
39
+ <tr>
40
+ <td>.volumeUp()</td>
41
+ <td>Increase playback volume</td>
42
+ <td>Arrow up</td>
43
+ </tr>
44
+ <tr>
45
+ <td>.volumeDown()</td>
46
+ <td>Decrease playback volume</td>
47
+ <td>Arrow down</td>
48
+ </tr>
49
+ <tr>
50
+ <td>.toggleMute()</td>
51
+ <td>Mute / Unmute audio</td>
52
+ <td>M</td>
53
+ </tr>
54
+ <tr>
55
+ <td>.toggleFullscreen()</td>
56
+ <td>Toggle fullscreen</td>
57
+ <td>F</td>
58
+ </tr>
59
+ <tr>
60
+ <td>.jumpForward()</td>
61
+ <td>Jump 10 seconds forward</td>
62
+ <td>L</td>
63
+ </tr>
64
+ <tr>
65
+ <td>.jumpBackward()</td>
66
+ <td>Jump 10 seconds backward</td>
67
+ <td>J</td>
68
+ </tr>
69
+ <tr>
70
+ <td>.frameForward()</td>
71
+ <td>Navigate to next frame</td>
72
+ <td>Arrow right</td>
73
+ </tr>
74
+ <tr>
75
+ <td>.frameBackward()</td>
76
+ <td>Navigate to previous frame</td>
77
+ <td>Arrow left</td>
78
+ </tr>
79
+ <tr>
80
+ <td>.toggleSubs()</td>
81
+ <td>Toggle subtitles on / off if any</td>
82
+ <td>C</td>
83
+ </tr>
84
+ <tr>
85
+ <td>.disableSubs()</td>
86
+ <td>Turn subtitles off</td>
87
+ <td />
88
+ </tr>
89
+ <tr>
90
+ <td>.enableSubs()</td>
91
+ <td>Turn subtitles on</td>
92
+ <td />
93
+ </tr>
94
+ <tr>
95
+ <td>.volume</td>
96
+ <td>Returns current volume level (0-1)</td>
97
+ <td />
98
+ </tr>
99
+ <tr>
100
+ <td>.volume = 0.345</td>
101
+ <td>Sets volume level (0-1)</td>
102
+ <td />
103
+ </tr>
104
+ <tr>
105
+ <td>.toStart()</td>
106
+ <td>Navigate to start of the video</td>
107
+ <td />
108
+ </tr>
109
+ <tr>
110
+ <td>.toEnd()</td>
111
+ <td>Navigate to end of the video</td>
112
+ <td />
113
+ </tr>
114
+ <tr>
115
+ <td>.destroy()</td>
116
+ <td>Deconstructor</td>
117
+ <td />
118
+ </tr>
119
+ </tbody>
120
+ </table>