cloudinary-video-player 1.6.2-edge.13

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 (226) hide show
  1. package/.eslintignore +4 -0
  2. package/.snyk +19 -0
  3. package/.travis.yml +8 -0
  4. package/CHANGELOG.md +329 -0
  5. package/LICENSE +21 -0
  6. package/README.md +87 -0
  7. package/dist/cld-video-player.css +2110 -0
  8. package/dist/cld-video-player.js +5249 -0
  9. package/dist/cld-video-player.light.css +1766 -0
  10. package/dist/cld-video-player.light.js +1399 -0
  11. package/dist/cld-video-player.light.min.css +1 -0
  12. package/dist/cld-video-player.light.min.js +2 -0
  13. package/dist/cld-video-player.light.min.js.LICENSE.txt +23 -0
  14. package/dist/cld-video-player.min.css +1 -0
  15. package/dist/cld-video-player.min.js +2 -0
  16. package/dist/cld-video-player.min.js.LICENSE.txt +26 -0
  17. package/dist/fonts/cloudinary_icon_for_black_bg.svg +69 -0
  18. package/dist/fonts/cloudinary_icon_for_white_bg.svg +69 -0
  19. package/docs/360.html +102 -0
  20. package/docs/_template.html +93 -0
  21. package/docs/adaptive-streaming.html +297 -0
  22. package/docs/analytics.html +140 -0
  23. package/docs/api.html +302 -0
  24. package/docs/audio.html +136 -0
  25. package/docs/autoplay-fallback.html +138 -0
  26. package/docs/autoplay-on-scroll.html +107 -0
  27. package/docs/codec-fallback.html +158 -0
  28. package/docs/colors.html +135 -0
  29. package/docs/components.html +284 -0
  30. package/docs/custom-cld-errors.html +134 -0
  31. package/docs/floating-player.html +98 -0
  32. package/docs/fluid.html +117 -0
  33. package/docs/force-hls-subtitles-ios.html +159 -0
  34. package/docs/index.html +83 -0
  35. package/docs/interaction-area.html +398 -0
  36. package/docs/live-customer.html +128 -0
  37. package/docs/multiple-players.html +125 -0
  38. package/docs/playlist-by-tag-cap.html +182 -0
  39. package/docs/playlist-by-tag.html +133 -0
  40. package/docs/playlist.html +133 -0
  41. package/docs/poster.html +155 -0
  42. package/docs/raw-url.html +104 -0
  43. package/docs/recommendations.html +155 -0
  44. package/docs/scripts.js +156 -0
  45. package/docs/seek-thumbs.html +90 -0
  46. package/docs/shoppable.html +335 -0
  47. package/docs/subtitles-and-captions.html +267 -0
  48. package/docs/transformations.html +171 -0
  49. package/docs/ui-config.html +108 -0
  50. package/docs/vast-vpaid.html +149 -0
  51. package/env.example.js +6 -0
  52. package/env.js +6 -0
  53. package/jest-puppeteer.config.js +14 -0
  54. package/jest.config.js +196 -0
  55. package/package.json +99 -0
  56. package/sandbox.config.json +3 -0
  57. package/setupJest.js +1 -0
  58. package/src/assets/fonts/VideoJS.svg +120 -0
  59. package/src/assets/fonts/VideoJS.ttf +0 -0
  60. package/src/assets/fonts/VideoJS.woff +0 -0
  61. package/src/assets/fonts/icons.json +120 -0
  62. package/src/assets/icons/cloudinary_icon_for_black_bg.svg +69 -0
  63. package/src/assets/icons/cloudinary_icon_for_white_bg.svg +69 -0
  64. package/src/assets/icons/cloudinary_logo_for_dark_bg.svg +188 -0
  65. package/src/assets/icons/cloudinary_logo_for_white_bg.svg +188 -0
  66. package/src/assets/icons/info-circle.svg +17 -0
  67. package/src/assets/styles/ads-label.scss +16 -0
  68. package/src/assets/styles/components/interaction-areas.scss +158 -0
  69. package/src/assets/styles/components/playlist.scss +213 -0
  70. package/src/assets/styles/components/themedButton.scss +48 -0
  71. package/src/assets/styles/components/thumbnail.scss +94 -0
  72. package/src/assets/styles/components/title-bar.scss +67 -0
  73. package/src/assets/styles/components/triangle-volume-bar.scss +52 -0
  74. package/src/assets/styles/icons.scss +257 -0
  75. package/src/assets/styles/main.scss +324 -0
  76. package/src/assets/styles/mixins/aspect-ratio.scss +16 -0
  77. package/src/assets/styles/mixins/disable-transition.scss +3 -0
  78. package/src/assets/styles/mixins/mixins.scss +5 -0
  79. package/src/assets/styles/mixins/skin.scss +64 -0
  80. package/src/assets/styles/variables.scss +2 -0
  81. package/src/assets/styles/videojs-ima.scss +252 -0
  82. package/src/components/component-utils.js +20 -0
  83. package/src/components/index.js +21 -0
  84. package/src/components/interaction-area/interaction-area.const.js +30 -0
  85. package/src/components/interaction-area/interaction-area.service.js +223 -0
  86. package/src/components/interaction-area/interaction-area.utils.js +236 -0
  87. package/src/components/jumpButtons/jump-10-minus.js +21 -0
  88. package/src/components/jumpButtons/jump-10-plus.js +20 -0
  89. package/src/components/logoButton/logo-button.const.js +3 -0
  90. package/src/components/logoButton/logo-button.js +30 -0
  91. package/src/components/logoButton/logo-button.scss +15 -0
  92. package/src/components/playlist/components/playlist-button.js +34 -0
  93. package/src/components/playlist/components/playlist-next-button.js +18 -0
  94. package/src/components/playlist/components/playlist-previous-button.js +18 -0
  95. package/src/components/playlist/components/playlist.js +5 -0
  96. package/src/components/playlist/components/playlist.scss +15 -0
  97. package/src/components/playlist/components/upcoming-video-overlay.js +149 -0
  98. package/src/components/playlist/components/upcoming-video-overlay.scss +86 -0
  99. package/src/components/playlist/layout/playlist-layout-custom.js +21 -0
  100. package/src/components/playlist/layout/playlist-layout-horizontal.js +16 -0
  101. package/src/components/playlist/layout/playlist-layout-vertical.js +19 -0
  102. package/src/components/playlist/layout/playlist-layout.js +110 -0
  103. package/src/components/playlist/panel/playlist-panel-item.js +86 -0
  104. package/src/components/playlist/panel/playlist-panel.js +92 -0
  105. package/src/components/playlist/playlist-widget.js +119 -0
  106. package/src/components/playlist/playlist.const.js +14 -0
  107. package/src/components/playlist/playlist.js +413 -0
  108. package/src/components/playlist/thumbnail/thumbnail.js +69 -0
  109. package/src/components/progress-control-events-blocker/progress-control-events-blocker.js +17 -0
  110. package/src/components/qualitySelector/quality-selector.scss +10 -0
  111. package/src/components/qualitySelector/qualitySelector.js +152 -0
  112. package/src/components/recommendations-overlay/index.js +3 -0
  113. package/src/components/recommendations-overlay/recommendations-overlay-content.js +57 -0
  114. package/src/components/recommendations-overlay/recommendations-overlay-hide-button.js +18 -0
  115. package/src/components/recommendations-overlay/recommendations-overlay-item.js +35 -0
  116. package/src/components/recommendations-overlay/recommendations-overlay-primary-item.js +81 -0
  117. package/src/components/recommendations-overlay/recommendations-overlay-secondary-item.js +48 -0
  118. package/src/components/recommendations-overlay/recommendations-overlay-secondary-items-container.js +35 -0
  119. package/src/components/recommendations-overlay/recommendations-overlay.js +94 -0
  120. package/src/components/recommendations-overlay/recommendations-overlay.scss +182 -0
  121. package/src/components/shoppable-bar/layout/bar-layout.js +111 -0
  122. package/src/components/shoppable-bar/layout/shoppable-panel-toggle.js +64 -0
  123. package/src/components/shoppable-bar/layout/shoppable-products-overlay.js +87 -0
  124. package/src/components/shoppable-bar/panel/shoppable-panel-item.js +105 -0
  125. package/src/components/shoppable-bar/panel/shoppable-panel.js +172 -0
  126. package/src/components/shoppable-bar/shoppable-post-widget.js +110 -0
  127. package/src/components/shoppable-bar/shoppable-widget.const.js +52 -0
  128. package/src/components/shoppable-bar/shoppable-widget.js +111 -0
  129. package/src/components/shoppable-bar/shoppable-widget.scss +359 -0
  130. package/src/components/themeButton/themedButton.const.js +3 -0
  131. package/src/components/themeButton/themedButton.js +25 -0
  132. package/src/components/title-bar/title-bar.js +79 -0
  133. package/src/config/defaults.js +25 -0
  134. package/src/extended-events.js +228 -0
  135. package/src/index.js +18 -0
  136. package/src/mixins/eventable.js +54 -0
  137. package/src/mixins/playlistable.js +106 -0
  138. package/src/plugins/analytics/index.js +245 -0
  139. package/src/plugins/autoplay-on-scroll/index.js +86 -0
  140. package/src/plugins/cloudinary/common.js +216 -0
  141. package/src/plugins/cloudinary/event-handler-registry.js +46 -0
  142. package/src/plugins/cloudinary/index.js +345 -0
  143. package/src/plugins/cloudinary/models/audio-source/audio-source.const.js +11 -0
  144. package/src/plugins/cloudinary/models/audio-source/audio-source.js +82 -0
  145. package/src/plugins/cloudinary/models/base-source.js +107 -0
  146. package/src/plugins/cloudinary/models/image-source.js +26 -0
  147. package/src/plugins/cloudinary/models/video-source/video-source.const.js +32 -0
  148. package/src/plugins/cloudinary/models/video-source/video-source.js +239 -0
  149. package/src/plugins/cloudinary/models/video-source/video-source.utils.js +57 -0
  150. package/src/plugins/colors/index.js +303 -0
  151. package/src/plugins/context-menu/components/context-menu-item.js +12 -0
  152. package/src/plugins/context-menu/components/context-menu.js +63 -0
  153. package/src/plugins/context-menu/context-menu.scss +30 -0
  154. package/src/plugins/context-menu/contextMenuContent.js +53 -0
  155. package/src/plugins/context-menu/index.js +134 -0
  156. package/src/plugins/dash/index.js +26 -0
  157. package/src/plugins/dash/setup-audio-tracks.js +112 -0
  158. package/src/plugins/dash/setup-text-tracks.js +195 -0
  159. package/src/plugins/dash/videojs-dash.js +372 -0
  160. package/src/plugins/floating-player/floating-player.scss +74 -0
  161. package/src/plugins/floating-player/index.js +129 -0
  162. package/src/plugins/ima/index.js +1775 -0
  163. package/src/plugins/index.js +31 -0
  164. package/src/plugins/interactive-plugin/index.js +10 -0
  165. package/src/plugins/videojs-http-source-selector/components/SourceMenuButton.js +98 -0
  166. package/src/plugins/videojs-http-source-selector/components/SourceMenuItem.js +52 -0
  167. package/src/plugins/videojs-http-source-selector/plugin.js +82 -0
  168. package/src/plugins/videojs-http-source-selector/plugin.scss +9 -0
  169. package/src/plugins/vtt-thumbnails/index.js +526 -0
  170. package/src/plugins/vtt-thumbnails/vtt-thumbnails.scss +29 -0
  171. package/src/utils/api.js +32 -0
  172. package/src/utils/apply-with-props.js +32 -0
  173. package/src/utils/array.js +22 -0
  174. package/src/utils/assign.js +27 -0
  175. package/src/utils/attributes-normalizer.js +72 -0
  176. package/src/utils/cloudinary.js +165 -0
  177. package/src/utils/css-prefix.js +43 -0
  178. package/src/utils/dom.js +74 -0
  179. package/src/utils/find.js +28 -0
  180. package/src/utils/fontFace.js +25 -0
  181. package/src/utils/groupBy.js +12 -0
  182. package/src/utils/index.js +29 -0
  183. package/src/utils/matches.js +11 -0
  184. package/src/utils/mixin.js +5 -0
  185. package/src/utils/object.js +26 -0
  186. package/src/utils/playButton.js +9 -0
  187. package/src/utils/positioning.js +78 -0
  188. package/src/utils/querystring.js +12 -0
  189. package/src/utils/slicing.js +21 -0
  190. package/src/utils/string.js +15 -0
  191. package/src/utils/throttle.js +30 -0
  192. package/src/utils/time.js +77 -0
  193. package/src/utils/type-inference.js +35 -0
  194. package/src/validators/validators-functions.js +48 -0
  195. package/src/validators/validators-types.js +78 -0
  196. package/src/validators/validators.js +110 -0
  197. package/src/video-player.const.js +68 -0
  198. package/src/video-player.js +761 -0
  199. package/src/video-player.utils.js +123 -0
  200. package/test/adaptive-streaming.test.js +38 -0
  201. package/test/ads.test.js +35 -0
  202. package/test/analytics.test.js +111 -0
  203. package/test/api.test.js +111 -0
  204. package/test/autoplay.scroll.test.js +23 -0
  205. package/test/basic-ui.test.js +59 -0
  206. package/test/colors.test.js +58 -0
  207. package/test/components.test.js +21 -0
  208. package/test/custom-error.test.js +24 -0
  209. package/test/fluid.test.js +36 -0
  210. package/test/isValidConfig.test.js +224 -0
  211. package/test/mocks/cloudinary-core-mock.js +0 -0
  212. package/test/mocks/styleMock.js +1 -0
  213. package/test/multiplayer.test.js +25 -0
  214. package/test/playlist.test.js +60 -0
  215. package/test/puppeteer/vp-env.js +19 -0
  216. package/test/recommendations.test.js +38 -0
  217. package/test/title-bar.test.js +28 -0
  218. package/test/ui-conf.test.js +49 -0
  219. package/test/unit/cloudinaryConfig.test.js +22 -0
  220. package/test/unit/cloudinaryUtils.test.js +53 -0
  221. package/test/unit/utils.test.js +27 -0
  222. package/test/unit/videoSource.test.js +454 -0
  223. package/tsconfig.json +15 -0
  224. package/types/video-player-tests.js +12 -0
  225. package/types/video-player-tests.ts +31 -0
  226. package/types/video-player.d.ts +570 -0
@@ -0,0 +1,16 @@
1
+ import PlaylistLayout from './playlist-layout';
2
+
3
+ class PlaylistLayoutHorizontal extends PlaylistLayout {
4
+ constructor (player, options) {
5
+ options.wrap = true;
6
+ super(player, options);
7
+ }
8
+
9
+ getCls() {
10
+ const cls = super.getCls();
11
+ cls.push('cld-plw-horizontal');
12
+ return cls;
13
+ }
14
+ }
15
+
16
+ export default PlaylistLayoutHorizontal;
@@ -0,0 +1,19 @@
1
+ import PlaylistLayout from './playlist-layout';
2
+
3
+ class PlaylistLayoutVertical extends PlaylistLayout {
4
+
5
+ constructor (player, options) {
6
+ options.wrap = true;
7
+ super(player, options);
8
+ }
9
+
10
+ getCls() {
11
+ const cls = super.getCls();
12
+ cls.push('cld-plw-vertical');
13
+
14
+ return cls;
15
+ }
16
+ }
17
+
18
+
19
+ export default PlaylistLayoutVertical;
@@ -0,0 +1,110 @@
1
+ import videojs from 'video.js';
2
+ import { wrap } from '../../../utils/dom';
3
+ import {
4
+ skinClassPrefix,
5
+ playerClassPrefix
6
+ } from '../../../utils/css-prefix';
7
+
8
+ const dom = videojs.dom || videojs;
9
+ const Component = videojs.getComponent('Component');
10
+
11
+ const OPTIONS_DEFAULT = {
12
+ wrap: false
13
+ };
14
+
15
+ class PlaylistLayout extends Component {
16
+ constructor(player, options) {
17
+ const layoutOptions = { ...OPTIONS_DEFAULT, ...options };
18
+ super(player, layoutOptions);
19
+ this.player_ = player;
20
+ this.setCls();
21
+
22
+ const fluidHandler = (e, fluid) => {
23
+ this.options_.fluid = fluid;
24
+ this.removeCls();
25
+ this.setCls();
26
+ };
27
+
28
+ const wrapVideoWithLayout = () => {
29
+ const el = this.el();
30
+
31
+ this.videoWrap_ = dom.createEl('div', { className: 'cld-plw-col-player' });
32
+ this.contentEl_ = this.contentEl_ = dom.createEl('div', { className: 'cld-plw-col-list' });
33
+
34
+ wrap(this.player().el(), el);
35
+
36
+ el.appendChild(this.videoWrap_);
37
+ el.appendChild(this.contentEl_);
38
+
39
+ wrap(this.player().el(), this.videoWrap_);
40
+ };
41
+
42
+ if (layoutOptions.wrap) {
43
+ wrapVideoWithLayout();
44
+ }
45
+
46
+ player.on('fluid', fluidHandler);
47
+
48
+ this.addChild('PlaylistPanel', this.options_);
49
+
50
+ this.dispose = () => {
51
+ this.removeLayout();
52
+ super.dispose();
53
+ player.off('fluid', fluidHandler);
54
+ };
55
+ }
56
+
57
+ getCls() {
58
+ let cls = ['cld-video-player', 'cld-plw-layout'];
59
+
60
+ cls.push(skinClassPrefix(this.player()));
61
+ cls.push(playerClassPrefix(this.player()));
62
+
63
+ if (this.options_.fluid) {
64
+ cls.push('cld-plw-layout-fluid');
65
+ }
66
+
67
+ return cls;
68
+ }
69
+
70
+ setCls() {
71
+ this.removeClass(skinClassPrefix(this));
72
+ this.getCls().forEach((cls) => {
73
+ this.addClass(cls);
74
+ });
75
+ }
76
+
77
+ removeCls() {
78
+ this.getCls().forEach((cls) => {
79
+ this.removeClass(cls);
80
+ });
81
+ }
82
+
83
+ update(optionToChange, options) {
84
+ this.options(options);
85
+ this.removeChild('PlaylistPanel');
86
+ this.addChild('PlaylistPanel', this.options_);
87
+ this.trigger('playlistlayoutupdate');
88
+ }
89
+
90
+ removeLayout() {
91
+ const parentElem = this.el().parentElement;
92
+ if (parentElem) {
93
+ parentElem.appendChild(this.player().el());
94
+ }
95
+ }
96
+
97
+ createEl() {
98
+ const el = super.createEl('div');
99
+
100
+ // Apply font styles on wrapper div.
101
+ el.style.fontFamily = this.player().el().style.fontFamily;
102
+
103
+ return el;
104
+ }
105
+
106
+ }
107
+
108
+ videojs.registerComponent('playlistLayout', PlaylistLayout);
109
+
110
+ export default PlaylistLayout;
@@ -0,0 +1,86 @@
1
+ import videojs from 'video.js';
2
+ import Thumbnail from '../thumbnail/thumbnail';
3
+
4
+ const dom = videojs.dom || videojs;
5
+
6
+ const DEFAULT_OPTIONS = {
7
+ source: null,
8
+ next: false
9
+ };
10
+
11
+ class PlaylistPanelItem extends Thumbnail {
12
+
13
+ constructor(player, initOptions) {
14
+ const options = videojs.mergeOptions(DEFAULT_OPTIONS, initOptions);
15
+ super(player, options);
16
+ }
17
+
18
+ handleClick(event) {
19
+ super.handleClick(event);
20
+ this.play();
21
+ }
22
+
23
+ play() {
24
+ const item = this.getItem();
25
+ const list = this.player().cloudinary.playlist().list();
26
+ const index = list.indexOf(item);
27
+
28
+ if (index === -1) {
29
+ throw new Error('Invalid playlist item...');
30
+ }
31
+
32
+ this.player().cloudinary.playlist().playAtIndex(index);
33
+ }
34
+
35
+ isCurrent() {
36
+ return this.options_.current;
37
+ }
38
+
39
+ getTitle() {
40
+ return super.getTitle();
41
+ }
42
+
43
+ getDuration() {
44
+ return super.getDuration();
45
+ }
46
+
47
+ createEl() {
48
+ const el = super.createEl();
49
+
50
+ el.classList.add('cld-plw-panel-item');
51
+
52
+ const info = dom.createEl('div', { className: 'cld-plw-item-info-wrap' });
53
+ const titleWrap = dom.createEl('div', { className: 'cld-plw-item-title' });
54
+
55
+ if (this.isCurrent()) {
56
+ el.classList.add('cld-plw-panel-item-active');
57
+
58
+ const currEl = dom.createEl('span', {
59
+ className: 'cld-plw-item-title-curr'
60
+ }, {}, 'Now Playing: ');
61
+
62
+ titleWrap.appendChild(currEl);
63
+ }
64
+
65
+ const title = dom.createEl('span', { className: 'cld-plw-item-title' }, {}, this.getTitle());
66
+
67
+ titleWrap.appendChild(title);
68
+
69
+ const duration = dom.createEl('div', { className: 'cld-plw-item-duration' }, {}, this.getDuration());
70
+
71
+ info.appendChild(titleWrap);
72
+ info.appendChild(duration);
73
+
74
+ if (el) {
75
+ el.appendChild(info);
76
+ }
77
+
78
+ el.appendChild(info);
79
+
80
+ return el;
81
+ }
82
+ }
83
+
84
+ videojs.registerComponent('playlistPanelItem', PlaylistPanelItem);
85
+
86
+ export default PlaylistPanelItem;
@@ -0,0 +1,92 @@
1
+ import videojs from 'video.js';
2
+ import 'assets/styles/components/playlist.scss';
3
+ import PlaylistPanelItem from './playlist-panel-item';
4
+
5
+
6
+ const Component = videojs.getComponent('Component');
7
+
8
+ class PlaylistPanel extends Component {
9
+
10
+ constructor(player, options = {}) {
11
+ super(player, options);
12
+
13
+ const itemChangeHandler = () => {
14
+ this.render();
15
+ };
16
+
17
+ player.on('playlistitemchanged', itemChangeHandler);
18
+
19
+ this.render();
20
+
21
+ this.dispose = () => {
22
+ super.dispose();
23
+ player.off('playlistitemchanged', itemChangeHandler);
24
+ };
25
+ }
26
+
27
+ createEl() {
28
+ const el = super.createEl();
29
+ el.classList.add('cld-plw-panel');
30
+
31
+ return el;
32
+ }
33
+
34
+ removeAll() {
35
+ const childrens = this.children();
36
+ for (let i = childrens.length - 1; i >= 0; --i) {
37
+ this.removeChild(childrens[i]);
38
+ }
39
+ }
40
+
41
+ getItems() {
42
+ const playlist = this.player().cloudinary.playlist();
43
+ const repeat = playlist._repeat;
44
+
45
+ if (this.options_.showAll) {
46
+ return playlist.list();
47
+ }
48
+
49
+ const items = [];
50
+ const numOfItems = this.options_.total;
51
+ let index = playlist.currentIndex();
52
+ let source = playlist.list()[index];
53
+ items.push(source);
54
+
55
+ while (items.length < numOfItems) {
56
+ index = playlist.nextIndex(index);
57
+ if (index === -1) {
58
+ if (!repeat && items.length > 0) {
59
+ break;
60
+ }
61
+
62
+ index = 0;
63
+ }
64
+
65
+ source = playlist.list()[index];
66
+ items.push(source);
67
+ }
68
+
69
+ return items;
70
+ }
71
+
72
+ render() {
73
+ const items = this.getItems();
74
+
75
+ this.removeAll();
76
+
77
+ items.forEach((source, index) => {
78
+ const playlistItem = new PlaylistPanelItem(this.player(), videojs.mergeOptions(this.options_, {
79
+ item: source,
80
+ next: index === 1,
81
+ current: index === 0
82
+ }));
83
+
84
+ this.addChild(playlistItem);
85
+
86
+ });
87
+ }
88
+ }
89
+
90
+ videojs.registerComponent('playlistPanel', PlaylistPanel);
91
+
92
+ export default PlaylistPanel;
@@ -0,0 +1,119 @@
1
+ import videojs from 'video.js';
2
+ import PlaylistLayoutHorizontal from './layout/playlist-layout-horizontal';
3
+ import PlaylistLayoutVertical from './layout/playlist-layout-vertical';
4
+ import PlaylistLayoutCustom from './layout/playlist-layout-custom';
5
+ import { PLAYLIST_DEFAULTS_OPTIONS } from './playlist.const';
6
+
7
+
8
+ const modifyOptions = (player, opt) => {
9
+ const options = { ...PLAYLIST_DEFAULTS_OPTIONS, ...opt };
10
+
11
+ if (options.show && typeof options.selector === 'string') {
12
+ options.useDefaultLayout = false;
13
+ options.useCustomLayout = true;
14
+ options.renderTo = document.querySelector(options.selector);
15
+ options.showAll = true;
16
+
17
+ if (!options.renderTo.length === 0) {
18
+ throw new Error(`Couldn't find element(s) by selector '${options.selector}' for playlist`);
19
+ }
20
+ }
21
+
22
+ if (options.show && !options.selector) {
23
+ options.useDefaultLayout = true;
24
+ options.useCustomLayout = false;
25
+ }
26
+
27
+ options.direction = options.direction.toLowerCase() === 'horizontal' ? 'horizontal' : 'vertical';
28
+
29
+ options.skin = player.options_.skin;
30
+
31
+ return options;
32
+ };
33
+
34
+
35
+ class PlaylistWidget {
36
+ constructor(player, options = {}) {
37
+ options = modifyOptions(player, options);
38
+ this.options_ = options;
39
+ this.player_ = player;
40
+ this.render();
41
+
42
+ const fluidHandler = (e, fluid) => {
43
+ this.options_.fluid = fluid;
44
+ };
45
+
46
+ player.on('fluid', fluidHandler);
47
+
48
+ this.options = (options) => {
49
+ if (!options) {
50
+ return this.options_;
51
+ }
52
+
53
+ this.options_ = videojs.mergeOptions(this.options_, options);
54
+ player.trigger('playlistwidgetoption', this.options_.playlistWidget);
55
+ return this.options_;
56
+
57
+ };
58
+
59
+ this.dispose = () => {
60
+ this.layout_.dispose();
61
+ player.off('fluid', fluidHandler);
62
+ };
63
+ }
64
+
65
+ render() {
66
+ if (this.options_.useDefaultLayout) {
67
+ if (this.options_.direction === 'horizontal') {
68
+ this.layout_ = new PlaylistLayoutHorizontal(this.player_, this.options_);
69
+ } else {
70
+ this.layout_ = new PlaylistLayoutVertical(this.player_, this.options_);
71
+ }
72
+ }
73
+
74
+ if (this.options_.useCustomLayout) {
75
+ this.layout_ = new PlaylistLayoutCustom(this.player_, this.options_);
76
+ }
77
+ }
78
+
79
+ getLayout() {
80
+ return this.layout_;
81
+ }
82
+
83
+ update(optionName, optionValue) {
84
+ this.options(optionValue);
85
+
86
+ if (optionName === 'direction') {
87
+ this.layout_.removeLayout();
88
+ this.layout_.dispose();
89
+ this.render();
90
+ } else {
91
+ this.layout_.update(optionName, this.options_);
92
+ }
93
+ }
94
+
95
+ setSkin() {
96
+ this.layout_.setCls();
97
+ }
98
+
99
+ total(totalNumber = PLAYLIST_DEFAULTS_OPTIONS.total) {
100
+ const total = parseInt(totalNumber, 10);
101
+
102
+ if (total !== this.options_.total && typeof total === 'number' && total > 0) {
103
+ this.update('total', { total: total });
104
+ }
105
+
106
+ return this;
107
+ }
108
+
109
+ direction(direction = PLAYLIST_DEFAULTS_OPTIONS.direction) {
110
+ if (direction === 'horizontal' || direction === 'vertical') {
111
+ this.update('direction', { direction: direction });
112
+ }
113
+
114
+ return this;
115
+ }
116
+ }
117
+
118
+
119
+ export default PlaylistWidget;
@@ -0,0 +1,14 @@
1
+ export const DEFAULT_AUTO_ADVANCE = 0;
2
+
3
+ export const DEFAULT_PRESENT_UPCOMING = 10;
4
+
5
+ export const UPCOMING_VIDEO_TRANSITION = 1;
6
+
7
+ export const PLAYLIST_DEFAULTS_OPTIONS = {
8
+ fluid: false,
9
+ show: true,
10
+ direction: 'vertical',
11
+ total: 4,
12
+ selector: false,
13
+ renderTo: []
14
+ };