cloudinary-video-player 3.12.1 → 3.12.2-edge.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.
Files changed (86) hide show
  1. package/dist/134.min.js +8 -0
  2. package/dist/309.min.js +6 -0
  3. package/dist/adaptive-streaming.js +9 -9
  4. package/dist/adaptive-streaming.min.js +2 -2
  5. package/dist/chapters.js +4 -4
  6. package/dist/chapters.min.js +3 -3
  7. package/dist/cld-player-core.js +37 -0
  8. package/dist/cld-player-core.min.js +6 -0
  9. package/dist/cld-video-player-lazy.js +494 -0
  10. package/dist/cld-video-player-lazy.min.js +6 -0
  11. package/dist/cld-video-player.css +2 -2
  12. package/dist/cld-video-player.js +366 -332
  13. package/dist/cld-video-player.light.js +366 -332
  14. package/dist/cld-video-player.light.min.js +4 -4
  15. package/dist/cld-video-player.min.css +2 -2
  16. package/dist/cld-video-player.min.js +4 -4
  17. package/dist/colors.js +4 -4
  18. package/dist/colors.min.js +2 -2
  19. package/dist/dash.js +6 -6
  20. package/dist/dash.min.js +2 -2
  21. package/dist/debug.js +8 -8
  22. package/dist/debug.min.js +3 -3
  23. package/dist/ima.js +9 -9
  24. package/dist/ima.min.js +2 -2
  25. package/dist/interaction-areas.js +11 -11
  26. package/dist/interaction-areas.min.js +2 -2
  27. package/dist/node_modules_lodash_throttle_js.js +8 -8
  28. package/dist/playlist.js +31 -31
  29. package/dist/playlist.min.js +3 -3
  30. package/dist/recommendations-overlay.js +10 -10
  31. package/dist/recommendations-overlay.min.js +2 -2
  32. package/dist/schema.json +19 -0
  33. package/dist/share.js +5 -5
  34. package/dist/share.min.js +3 -3
  35. package/dist/shoppable.js +12 -12
  36. package/dist/shoppable.min.js +2 -2
  37. package/dist/utils_fetch-config_js.js +81 -0
  38. package/dist/video-player_js.js +3111 -0
  39. package/dist/visual-search.js +7 -7
  40. package/dist/visual-search.min.js +2 -2
  41. package/lib/_commonjsHelpers.js +7 -0
  42. package/lib/_videojs-proxy.js +30294 -0
  43. package/lib/abr-strategies.js +31 -0
  44. package/lib/adaptive-streaming.js +468 -2
  45. package/lib/all.js +25 -2
  46. package/lib/chapters.js +205 -1
  47. package/lib/cld-video-player.min.css +5 -22
  48. package/lib/colors.js +59 -1
  49. package/lib/{schema.json → config/configSchema.json} +19 -0
  50. package/lib/dash.js +69943 -2
  51. package/lib/debug.js +322 -1
  52. package/lib/document.js +770 -0
  53. package/lib/download-button.js +48 -0
  54. package/lib/fetch-config.js +93 -0
  55. package/lib/ima.js +6851 -1
  56. package/lib/index.js +27 -0
  57. package/lib/interaction-areas.const.js +24 -0
  58. package/lib/interaction-areas.service.js +469 -0
  59. package/lib/lazy.js +20 -0
  60. package/lib/noop.js +33 -0
  61. package/lib/player-api.js +469 -0
  62. package/lib/player.js +7 -2
  63. package/lib/playlist-panel.js +602 -0
  64. package/lib/playlist.js +637 -1
  65. package/lib/querystring.js +81 -0
  66. package/lib/recommendations-overlay.js +320 -1
  67. package/lib/share.js +129 -1
  68. package/lib/shoppable-post-widget.js +572 -0
  69. package/lib/shoppable-widget.js +77 -0
  70. package/lib/throttle.js +318 -0
  71. package/lib/toNumber.js +134 -0
  72. package/lib/validators-functions.js +485 -0
  73. package/lib/video-player.js +16241 -0
  74. package/lib/videoPlayer.js +7 -2
  75. package/lib/videojs-contrib-hlsjs.js +37638 -0
  76. package/lib/visual-search.js +235 -1
  77. package/package.json +31 -15
  78. package/lib/adaptive-streaming.js.LICENSE.txt +0 -3
  79. package/lib/all.js.LICENSE.txt +0 -25
  80. package/lib/cld-video-player.js +0 -2
  81. package/lib/cld-video-player.js.LICENSE.txt +0 -21
  82. package/lib/dash.js.LICENSE.txt +0 -1842
  83. package/lib/interaction-areas.js +0 -1
  84. package/lib/player.js.LICENSE.txt +0 -21
  85. package/lib/shoppable.js +0 -1
  86. package/lib/videoPlayer.js.LICENSE.txt +0 -21
@@ -0,0 +1,602 @@
1
+ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.js';
2
+ import { r as requireToNumber } from './toNumber.js';
3
+ import { _ as _vjs } from './_videojs-proxy.js';
4
+ import { P as PLAYER_EVENT, m as skinClassPrefix, p as playerClassPrefix } from './video-player.js';
5
+
6
+ var toFinite_1;
7
+ var hasRequiredToFinite;
8
+
9
+ function requireToFinite () {
10
+ if (hasRequiredToFinite) return toFinite_1;
11
+ hasRequiredToFinite = 1;
12
+ var toNumber = requireToNumber();
13
+
14
+ /** Used as references for various `Number` constants. */
15
+ var INFINITY = 1 / 0,
16
+ MAX_INTEGER = 1.7976931348623157e+308;
17
+
18
+ /**
19
+ * Converts `value` to a finite number.
20
+ *
21
+ * @static
22
+ * @memberOf _
23
+ * @since 4.12.0
24
+ * @category Lang
25
+ * @param {*} value The value to convert.
26
+ * @returns {number} Returns the converted number.
27
+ * @example
28
+ *
29
+ * _.toFinite(3.2);
30
+ * // => 3.2
31
+ *
32
+ * _.toFinite(Number.MIN_VALUE);
33
+ * // => 5e-324
34
+ *
35
+ * _.toFinite(Infinity);
36
+ * // => 1.7976931348623157e+308
37
+ *
38
+ * _.toFinite('3.2');
39
+ * // => 3.2
40
+ */
41
+ function toFinite(value) {
42
+ if (!value) {
43
+ return value === 0 ? value : 0;
44
+ }
45
+ value = toNumber(value);
46
+ if (value === INFINITY || value === -INFINITY) {
47
+ var sign = (value < 0 ? -1 : 1);
48
+ return sign * MAX_INTEGER;
49
+ }
50
+ return value === value ? value : 0;
51
+ }
52
+
53
+ toFinite_1 = toFinite;
54
+ return toFinite_1;
55
+ }
56
+
57
+ var toInteger_1;
58
+ var hasRequiredToInteger;
59
+
60
+ function requireToInteger () {
61
+ if (hasRequiredToInteger) return toInteger_1;
62
+ hasRequiredToInteger = 1;
63
+ var toFinite = requireToFinite();
64
+
65
+ /**
66
+ * Converts `value` to an integer.
67
+ *
68
+ * **Note:** This method is loosely based on
69
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
70
+ *
71
+ * @static
72
+ * @memberOf _
73
+ * @since 4.0.0
74
+ * @category Lang
75
+ * @param {*} value The value to convert.
76
+ * @returns {number} Returns the converted integer.
77
+ * @example
78
+ *
79
+ * _.toInteger(3.2);
80
+ * // => 3
81
+ *
82
+ * _.toInteger(Number.MIN_VALUE);
83
+ * // => 0
84
+ *
85
+ * _.toInteger(Infinity);
86
+ * // => 1.7976931348623157e+308
87
+ *
88
+ * _.toInteger('3.2');
89
+ * // => 3
90
+ */
91
+ function toInteger(value) {
92
+ var result = toFinite(value),
93
+ remainder = result % 1;
94
+
95
+ return result === result ? (remainder ? result - remainder : result) : 0;
96
+ }
97
+
98
+ toInteger_1 = toInteger;
99
+ return toInteger_1;
100
+ }
101
+
102
+ var isInteger_1;
103
+ var hasRequiredIsInteger;
104
+
105
+ function requireIsInteger () {
106
+ if (hasRequiredIsInteger) return isInteger_1;
107
+ hasRequiredIsInteger = 1;
108
+ var toInteger = requireToInteger();
109
+
110
+ /**
111
+ * Checks if `value` is an integer.
112
+ *
113
+ * **Note:** This method is based on
114
+ * [`Number.isInteger`](https://mdn.io/Number/isInteger).
115
+ *
116
+ * @static
117
+ * @memberOf _
118
+ * @since 4.0.0
119
+ * @category Lang
120
+ * @param {*} value The value to check.
121
+ * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
122
+ * @example
123
+ *
124
+ * _.isInteger(3);
125
+ * // => true
126
+ *
127
+ * _.isInteger(Number.MIN_VALUE);
128
+ * // => false
129
+ *
130
+ * _.isInteger(Infinity);
131
+ * // => false
132
+ *
133
+ * _.isInteger('3');
134
+ * // => false
135
+ */
136
+ function isInteger(value) {
137
+ return typeof value == 'number' && value == toInteger(value);
138
+ }
139
+
140
+ isInteger_1 = isInteger;
141
+ return isInteger_1;
142
+ }
143
+
144
+ var isIntegerExports = requireIsInteger();
145
+ var isInteger = /*@__PURE__*/getDefaultExportFromCjs(isIntegerExports);
146
+
147
+ // support VJS5 & VJS6 at the same time
148
+ const dom$2 = _vjs.dom || _vjs;
149
+ const Component$2 = _vjs.getComponent('Component');
150
+ const ClickableComponent$2 = _vjs.getComponent('ClickableComponent');
151
+ class UpcomingVideoOverlay extends ClickableComponent$2 {
152
+ static DISABLE_TRANSITION_CLASS = 'disable-transition';
153
+ static VJS_UPCOMING_VIDEO_SHOW = 'vjs-upcoming-video-show';
154
+ constructor(player) {
155
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
156
+ args[_key - 1] = arguments[_key];
157
+ }
158
+ super(player, ...args);
159
+ this._setEvents(player);
160
+ }
161
+ _setEvents(player) {
162
+ player.on(PLAYER_EVENT.UP_COMING_VIDEO_SHOW, this._show);
163
+ player.on(PLAYER_EVENT.UP_COMING_VIDEO_HIDE, this._hide);
164
+ player.on(PLAYER_EVENT.PLAYLIST_ITEM_CHANGED, this._onPlaylistItemChange);
165
+ }
166
+ _hide = () => {
167
+ this.removeClass(UpcomingVideoOverlay.VJS_UPCOMING_VIDEO_SHOW);
168
+ };
169
+ _disableTransition(block) {
170
+ this.addClass(UpcomingVideoOverlay.DISABLE_TRANSITION_CLASS);
171
+ block();
172
+ this.removeClass(UpcomingVideoOverlay.DISABLE_TRANSITION_CLASS);
173
+ }
174
+ _onPlaylistItemChange = (_, event) => {
175
+ this._hide();
176
+ this._disableTransition(() => {
177
+ if (event.next) {
178
+ this.setItem(event.next);
179
+ }
180
+ });
181
+ };
182
+ _show = () => {
183
+ const ima = this.player().ima;
184
+ const adsManager = ima === 'object' && ima.getAdsManager();
185
+ if (adsManager) {
186
+ if (!adsManager.getCurrentAd() || adsManager.getCurrentAd().isLinear()) {
187
+ this.addClass(UpcomingVideoOverlay.VJS_UPCOMING_VIDEO_SHOW);
188
+ }
189
+ } else {
190
+ this.addClass(UpcomingVideoOverlay.VJS_UPCOMING_VIDEO_SHOW);
191
+ }
192
+ };
193
+ setTitle(source) {
194
+ const title = this.getChild('upcomingVideoOverlayContent').getChild('upcomingVideoOverlayBar').getChild('upcomingVideoOverlayTitle');
195
+ title.setContent(source.info().title || source.publicId());
196
+ }
197
+ setItem(source) {
198
+ this._source = source;
199
+ const maxWidth = parseInt(window.getComputedStyle(this.el(), null).getPropertyValue('max-width'), 10);
200
+ const maxHeight = Math.round(maxWidth * (9 / 16.0));
201
+ const transformation = {
202
+ crop: 'pad',
203
+ background: 'auto:predominant',
204
+ width: maxWidth,
205
+ height: maxHeight
206
+ };
207
+ const content = this.getChild('upcomingVideoOverlayContent');
208
+ this.setTitle(source);
209
+ content.el().style.backgroundImage = `url("${this._source.poster().url({
210
+ transformation
211
+ })}")`;
212
+ }
213
+ handleClick() {
214
+ super.handleClick(event);
215
+ this.player().cloudinary.playlist().playNext();
216
+ }
217
+ createEl() {
218
+ return super.createEl('div', {
219
+ className: 'vjs-upcoming-video'
220
+ });
221
+ }
222
+ }
223
+ class UpcomingVideoOverlayContent extends Component$2 {
224
+ createEl() {
225
+ // Content wraps image and bar
226
+ return super.createEl('div', {
227
+ className: 'upcoming-video-overlay aspect-ratio-content'
228
+ });
229
+ }
230
+ }
231
+ class UpcomingVideoOverlayTitle extends Component$2 {
232
+ setContent(title) {
233
+ this._contentSpan.innerText = title;
234
+ }
235
+ createEl() {
236
+ const el = super.createEl('div', {
237
+ className: 'vjs-control vjs-upcoming-video-title'
238
+ });
239
+ const container = dom$2.createEl('div', {
240
+ className: 'vjs-upcoming-video-title-display',
241
+ innerHTML: '<span class="vjs-control-text">Next up</span>Next up: '
242
+ });
243
+ this._contentSpan = dom$2.createEl('span', {
244
+ className: 'vjs-upcoming-video-title-display-label'
245
+ });
246
+ container.appendChild(this._contentSpan);
247
+ el.appendChild(container);
248
+ return el;
249
+ }
250
+ }
251
+ class UpcomingVideoOverlayBar extends Component$2 {
252
+ createEl() {
253
+ return super.createEl('div', {
254
+ className: 'vjs-upcoming-video-bar'
255
+ });
256
+ }
257
+ }
258
+ UpcomingVideoOverlay.prototype.options_ = {
259
+ children: ['upcomingVideoOverlayContent']
260
+ };
261
+ _vjs.registerComponent('upcomingVideoOverlay', UpcomingVideoOverlay);
262
+ UpcomingVideoOverlayContent.prototype.options_ = {
263
+ children: ['upcomingVideoOverlayBar']
264
+ };
265
+ _vjs.registerComponent('upcomingVideoOverlayContent', UpcomingVideoOverlayContent);
266
+ UpcomingVideoOverlayBar.prototype.options_ = {
267
+ children: ['upcomingVideoOverlayTitle', 'playlistNextButton']
268
+ };
269
+ _vjs.registerComponent('upcomingVideoOverlayBar', UpcomingVideoOverlayBar);
270
+ _vjs.registerComponent('upcomingVideoOverlayTitle', UpcomingVideoOverlayTitle);
271
+
272
+ // Get the ClickableComponent base class from Video.js
273
+ const ClickableComponent$1 = _vjs.getComponent('ClickableComponent');
274
+
275
+ // Create a common class for playlist buttons
276
+ class PlaylistButton extends ClickableComponent$1 {
277
+ constructor(player, options) {
278
+ // It is important to invoke the superclass before anything else,
279
+ // to get all the features of components out of the box!
280
+ super(player, options);
281
+ const type = options.type;
282
+ if (!type && type !== 'previous' && type !== 'next') {
283
+ throw new Error('Type must be either \'previous\' or \'next\'');
284
+ }
285
+ }
286
+
287
+ // The `createEl` function of a component creates its DOM element.
288
+ createEl() {
289
+ const type = this.options_.type;
290
+ const typeCssClass = `vjs-icon-${type}-item`;
291
+ return _vjs.dom.createEl('button', {
292
+ // Prefixing classes of elements within a player with "vjs-"
293
+ // is a convention used in Video.js.
294
+ className: `vjs-control vjs-playlist-button vjs-button ${typeCssClass}`,
295
+ ariaLabel: `Playlist ${type} item`
296
+ });
297
+ }
298
+ }
299
+
300
+ class PlaylistNextButton extends PlaylistButton {
301
+ constructor(player) {
302
+ super(player, {
303
+ type: 'next'
304
+ });
305
+ }
306
+ handleClick(event) {
307
+ event.stopPropagation();
308
+ super.handleClick(event);
309
+ this.player().cloudinary.playlist().playNext();
310
+ }
311
+ }
312
+ _vjs.registerComponent('PlaylistNextButton', PlaylistNextButton);
313
+
314
+ class PlaylistPreviousButton extends PlaylistButton {
315
+ constructor(player) {
316
+ super(player, {
317
+ type: 'previous'
318
+ });
319
+ }
320
+ handleClick(event) {
321
+ super.handleClick(event);
322
+ this.player().cloudinary.playlist().playPrevious();
323
+ }
324
+ }
325
+ _vjs.registerComponent('PlaylistPreviousButton', PlaylistPreviousButton);
326
+
327
+ const wrap = (el, wrapper) => {
328
+ el.parentNode.insertBefore(wrapper, el);
329
+ wrapper.appendChild(el);
330
+ return wrapper;
331
+ };
332
+
333
+ const dom$1 = _vjs.dom || _vjs;
334
+ const Component$1 = _vjs.getComponent('Component');
335
+ const OPTIONS_DEFAULT = {
336
+ wrap: false
337
+ };
338
+ class PlaylistLayout extends Component$1 {
339
+ constructor(player, options) {
340
+ const layoutOptions = {
341
+ ...OPTIONS_DEFAULT,
342
+ ...options
343
+ };
344
+ super(player, layoutOptions);
345
+ this.player_ = player;
346
+ const fluidHandler = (e, fluid) => {
347
+ this.options_.fluid = fluid;
348
+ this.removeCls();
349
+ this.setCls();
350
+ };
351
+ const wrapVideoWithLayout = () => {
352
+ const el = this.el();
353
+ this.videoWrap_ = dom$1.createEl('div', {
354
+ className: 'cld-plw-col-player'
355
+ });
356
+ this.contentEl_ = this.contentEl_ = dom$1.createEl('div', {
357
+ className: 'cld-plw-col-list'
358
+ });
359
+ wrap(this.player().el(), el);
360
+ el.appendChild(this.videoWrap_);
361
+ el.appendChild(this.contentEl_);
362
+ wrap(this.player().el(), this.videoWrap_);
363
+ };
364
+ if (layoutOptions.wrap) {
365
+ wrapVideoWithLayout();
366
+ }
367
+ player.on(PLAYER_EVENT.FLUID, fluidHandler);
368
+ this.addChild(PLAYER_EVENT.PLAYLIST_PANEL, this.options_);
369
+ this.setCls();
370
+ this.dispose = () => {
371
+ this.removeLayout();
372
+ super.dispose();
373
+ player.off(PLAYER_EVENT.FLUID, fluidHandler);
374
+ };
375
+ }
376
+ getCls() {
377
+ let cls = ['cld-video-player', 'cld-plw-layout'];
378
+ cls.push(skinClassPrefix(this.player()));
379
+ cls.push(playerClassPrefix(this.player()));
380
+ if (this.options_.fluid) {
381
+ cls.push('cld-plw-layout-fluid');
382
+ }
383
+ return cls;
384
+ }
385
+ setCls() {
386
+ this.removeClass(skinClassPrefix(this.player()));
387
+ this.getCls().forEach(cls => {
388
+ this.addClass(cls);
389
+ });
390
+ }
391
+ removeCls() {
392
+ this.getCls().forEach(cls => {
393
+ this.removeClass(cls);
394
+ });
395
+ }
396
+ update(optionToChange, options) {
397
+ this.options(options);
398
+ this.removeChild('PlaylistPanel');
399
+ this.addChild('PlaylistPanel', this.options_);
400
+ this.trigger('playlistlayoutupdate');
401
+ }
402
+ removeLayout() {
403
+ const parentElem = this.el().parentElement;
404
+ if (parentElem) {
405
+ parentElem.appendChild(this.player().el());
406
+ }
407
+ }
408
+ createEl() {
409
+ const el = super.createEl('div');
410
+
411
+ // Apply font styles on wrapper div.
412
+ el.style.fontFamily = this.player().el().style.fontFamily;
413
+ return el;
414
+ }
415
+ }
416
+ _vjs.registerComponent('playlistLayout', PlaylistLayout);
417
+
418
+ // Get the ClickableComponent base class from Video.js
419
+ const ClickableComponent = _vjs.getComponent('ClickableComponent');
420
+ const THUMB_DEFAULT_WIDTH = 300;
421
+ const DEFAULT_OPTIONS$1 = {
422
+ item: null,
423
+ transformation: {
424
+ width: THUMB_DEFAULT_WIDTH,
425
+ aspect_ratio: '16:9',
426
+ crop: 'pad',
427
+ background: 'black'
428
+ }
429
+ };
430
+ class Thumbnail extends ClickableComponent {
431
+ constructor(player, initOptions) {
432
+ const options = _vjs.obj.merge(DEFAULT_OPTIONS$1, initOptions);
433
+ super(player, options);
434
+ }
435
+ getItem() {
436
+ return this.options_.item;
437
+ }
438
+ getTitle() {
439
+ return this.getItem().info().title;
440
+ }
441
+ getDuration() {
442
+ return ' '; // this.getItem().info().title;
443
+ }
444
+ getThumbnail() {
445
+ return this.getItem().poster().url({
446
+ transformation: this.options_.transformation
447
+ });
448
+ }
449
+ handleClick(e) {
450
+ e.preventDefault();
451
+ }
452
+ createControlTextEl() {
453
+ return;
454
+ }
455
+ createEl() {
456
+ let tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'a';
457
+ const el = super.createEl(tag, {
458
+ className: 'cld-thumbnail',
459
+ href: '#'
460
+ });
461
+ const img = super.createEl('img', {
462
+ className: 'cld-thumbnail-img',
463
+ src: this.getThumbnail()
464
+ });
465
+ el.appendChild(img);
466
+ el.style.backgroundImage = `url('${this.getThumbnail()}')`;
467
+ return el;
468
+ }
469
+ }
470
+
471
+ const dom = _vjs.dom || _vjs;
472
+ const DEFAULT_OPTIONS = {
473
+ source: null,
474
+ next: false
475
+ };
476
+ class PlaylistPanelItem extends Thumbnail {
477
+ constructor(player, initOptions) {
478
+ const options = _vjs.obj.merge(DEFAULT_OPTIONS, initOptions);
479
+ super(player, options);
480
+ }
481
+ handleClick(event) {
482
+ super.handleClick(event);
483
+ this.play();
484
+ }
485
+ play() {
486
+ const item = this.getItem();
487
+ const list = this.player().cloudinary.playlist().list();
488
+ const index = list.indexOf(item);
489
+ if (index === -1) {
490
+ throw new Error('Invalid playlist item...');
491
+ }
492
+ this.player().cloudinary.playlist().playAtIndex(index);
493
+ }
494
+ isCurrent() {
495
+ return this.options_.current;
496
+ }
497
+ getTitle() {
498
+ return super.getTitle();
499
+ }
500
+ getDuration() {
501
+ return super.getDuration();
502
+ }
503
+ createEl() {
504
+ const el = super.createEl();
505
+ el.classList.add('cld-plw-panel-item');
506
+ const info = dom.createEl('div', {
507
+ className: 'cld-plw-item-info-wrap'
508
+ });
509
+ const titleWrap = dom.createEl('div', {
510
+ className: 'cld-plw-item-title'
511
+ });
512
+ if (this.isCurrent()) {
513
+ el.classList.add('cld-plw-panel-item-active');
514
+ const currEl = dom.createEl('span', {
515
+ className: 'cld-plw-item-title-curr'
516
+ }, {}, 'Now Playing: ');
517
+ titleWrap.appendChild(currEl);
518
+ }
519
+ const title = dom.createEl('span', {
520
+ className: 'cld-plw-item-title'
521
+ }, {}, this.getTitle());
522
+ titleWrap.appendChild(title);
523
+ const duration = dom.createEl('div', {
524
+ className: 'cld-plw-item-duration'
525
+ }, {}, this.getDuration());
526
+ info.appendChild(titleWrap);
527
+ info.appendChild(duration);
528
+ if (el) {
529
+ el.appendChild(info);
530
+ }
531
+ el.appendChild(info);
532
+ return el;
533
+ }
534
+ }
535
+ _vjs.registerComponent('playlistPanelItem', PlaylistPanelItem);
536
+
537
+ const Component = _vjs.getComponent('Component');
538
+ class PlaylistPanel extends Component {
539
+ constructor(player) {
540
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
541
+ super(player, options);
542
+ const itemChangeHandler = () => {
543
+ this.render();
544
+ };
545
+ player.on(PLAYER_EVENT.PLAYLIST_ITEM_CHANGED, itemChangeHandler);
546
+ this.render();
547
+ this.dispose = () => {
548
+ super.dispose();
549
+ player.off(PLAYER_EVENT.PLAYLIST_ITEM_CHANGED, itemChangeHandler);
550
+ };
551
+ }
552
+ createEl() {
553
+ const el = super.createEl();
554
+ el.classList.add('cld-plw-panel');
555
+ return el;
556
+ }
557
+ removeAll() {
558
+ const children = this.children();
559
+ for (let i = children.length - 1; i >= 0; --i) {
560
+ this.removeChild(children[i]);
561
+ }
562
+ }
563
+ getItems() {
564
+ const playlist = this.player().cloudinary.playlist();
565
+ const repeat = playlist._repeat;
566
+ if (this.options_.showAll) {
567
+ return playlist.list();
568
+ }
569
+ const items = [];
570
+ const numOfItems = this.options_.total;
571
+ let index = playlist.currentIndex();
572
+ let source = playlist.list()[index];
573
+ items.push(source);
574
+ while (items.length < numOfItems) {
575
+ index = playlist.nextIndex(index);
576
+ if (index === -1) {
577
+ if (!repeat && items.length > 0) {
578
+ break;
579
+ }
580
+ index = 0;
581
+ }
582
+ source = playlist.list()[index];
583
+ items.push(source);
584
+ }
585
+ return items;
586
+ }
587
+ render() {
588
+ const items = this.getItems();
589
+ this.removeAll();
590
+ items.forEach((source, index) => {
591
+ const playlistItem = new PlaylistPanelItem(this.player(), _vjs.obj.merge(this.options_, {
592
+ item: source,
593
+ next: index === 1,
594
+ current: index === 0
595
+ }));
596
+ this.addChild(playlistItem);
597
+ });
598
+ }
599
+ }
600
+ _vjs.registerComponent('playlistPanel', PlaylistPanel);
601
+
602
+ export { PlaylistLayout as P, isInteger as i };