@gcorevideo/player 2.21.4 → 2.21.6

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/dist/index.js CHANGED
@@ -43300,7 +43300,7 @@ class Player {
43300
43300
  }
43301
43301
  }
43302
43302
 
43303
- var version$1 = "2.21.4";
43303
+ var version$1 = "2.21.6";
43304
43304
 
43305
43305
  var packages = {
43306
43306
  "node_modules/@clappr/core": {
@@ -43940,6 +43940,12 @@ const fullscreenOnIcon = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"
43940
43940
  // Copyright 2014 Globo.com Player authors. All rights reserved.
43941
43941
  // Use of this source code is governed by a BSD-style
43942
43942
  // license that can be found in the {@link https://github.com/clappr/clappr-plugins/blob/master/LICENSE | LICENSE}.
43943
+ const DEFAULT_SETTINGS = {
43944
+ left: [],
43945
+ right: [],
43946
+ default: [],
43947
+ seekEnabled: true,
43948
+ };
43943
43949
  /**
43944
43950
  * Custom events emitted by the plugins to communicate with one another
43945
43951
  * @beta
@@ -43955,7 +43961,8 @@ const T$e = 'plugins.media_control';
43955
43961
  const LEFT_ORDER = [
43956
43962
  'playpause',
43957
43963
  'playstop',
43958
- 'live',
43964
+ // 'live',
43965
+ 'dvr',
43959
43966
  'volume',
43960
43967
  'position',
43961
43968
  'duration',
@@ -43989,14 +43996,13 @@ class MediaControl extends UICorePlugin {
43989
43996
  hideId = null;
43990
43997
  hideVolumeId = null;
43991
43998
  intendedVolume = 100;
43992
- isHD = false;
43993
43999
  keepVisible = false;
43994
44000
  kibo;
43995
44001
  lastMouseX = 0;
43996
44002
  lastMouseY = 0;
43997
44003
  persistConfig;
43998
44004
  rendered = false;
43999
- settings = {}; // TODO & seekEnabled: boolean, ...
44005
+ settings = DEFAULT_SETTINGS;
44000
44006
  userDisabled = false;
44001
44007
  userKeepVisible = false;
44002
44008
  verticalVolume = false;
@@ -44140,8 +44146,6 @@ class MediaControl extends UICorePlugin {
44140
44146
  * @internal
44141
44147
  */
44142
44148
  bindEvents() {
44143
- // @ts-ignore
44144
- this.stopListening();
44145
44149
  this.listenTo(this.core, Events$1.CORE_ACTIVE_CONTAINER_CHANGED, this.onActiveContainerChanged);
44146
44150
  this.listenTo(this.core, Events$1.CORE_MOUSE_MOVE, this.show);
44147
44151
  this.listenTo(this.core, Events$1.CORE_MOUSE_LEAVE, () => this.hide(this.options.hideMediaControlDelay));
@@ -44178,8 +44182,8 @@ class MediaControl extends UICorePlugin {
44178
44182
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_TIMEUPDATE, this.onTimeUpdate);
44179
44183
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PROGRESS, this.updateProgressBar);
44180
44184
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_SETTINGSUPDATE, this.updateSettings);
44181
- this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PLAYBACKDVRSTATECHANGED, this.updateSettings);
44182
- this.listenTo(this.core.activeContainer, Events$1.CONTAINER_HIGHDEFINITIONUPDATE, this.highDefinitionUpdate);
44185
+ this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PLAYBACKDVRSTATECHANGED, this.onDvrStateChanged);
44186
+ this.listenTo(this.core.activeContainer, Events$1.CONTAINER_HIGHDEFINITIONUPDATE, this.onHdUpdate);
44183
44187
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_MEDIACONTROL_DISABLE, this.disable);
44184
44188
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_MEDIACONTROL_ENABLE, this.enable);
44185
44189
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_ENDED, this.ended);
@@ -44227,7 +44231,13 @@ class MediaControl extends UICorePlugin {
44227
44231
  // see https://github.com/clappr/clappr/issues/1127
44228
44232
  if (!Fullscreen.fullscreenEnabled() && video.webkitSupportsFullscreen) {
44229
44233
  this.fullScreenOnVideoTagSupported = true;
44230
- this.updateSettings();
44234
+ }
44235
+ this.updateSettings();
44236
+ if (this.core.activeContainer.getPlaybackType() === Playback.LIVE) {
44237
+ this.$el.addClass('live');
44238
+ }
44239
+ else {
44240
+ this.$el.removeClass('live');
44231
44241
  }
44232
44242
  }
44233
44243
  updateVolumeUI() {
@@ -44236,8 +44246,6 @@ class MediaControl extends UICorePlugin {
44236
44246
  return;
44237
44247
  }
44238
44248
  assert.ok(this.$volumeBarContainer, 'volume bar container must be present');
44239
- // update volume bar scrubber/fill on bar mode
44240
- // this.$volumeBarContainer.find('.bar-fill-2').css({});
44241
44249
  const containerWidth = this.$volumeBarContainer.width();
44242
44250
  assert.ok(this.$volumeBarBackground, 'volume bar background must be present');
44243
44251
  const barWidth = this.$volumeBarBackground.width();
@@ -44426,17 +44434,18 @@ class MediaControl extends UICorePlugin {
44426
44434
  // if the container is not ready etc
44427
44435
  this.intendedVolume = value;
44428
44436
  this.persistConfig && !isInitialVolume && Config.persist('volume', value);
44437
+ // TODO
44429
44438
  const setWhenContainerReady = () => {
44430
- if (this.container && this.container.isReady) {
44431
- this.container.setVolume(value);
44439
+ if (this.core.activeContainer && this.core.activeContainer.isReady) {
44440
+ this.core.activeContainer.setVolume(value);
44432
44441
  }
44433
44442
  else {
44434
- this.listenToOnce(this.container, Events$1.CONTAINER_READY, () => {
44435
- this.container.setVolume(value);
44443
+ this.listenToOnce(this.core.activeContainer, Events$1.CONTAINER_READY, () => {
44444
+ this.core.activeContainer.setVolume(value);
44436
44445
  });
44437
44446
  }
44438
44447
  };
44439
- if (!this.container) {
44448
+ if (!this.core.activeContainer) {
44440
44449
  this.listenToOnce(this, Events$1.MEDIACONTROL_CONTAINERCHANGED, () => setWhenContainerReady());
44441
44450
  }
44442
44451
  else {
@@ -44446,7 +44455,7 @@ class MediaControl extends UICorePlugin {
44446
44455
  toggleFullscreen() {
44447
44456
  if (!Browser.isMobile) {
44448
44457
  this.trigger(Events$1.MEDIACONTROL_FULLSCREEN, this.name);
44449
- this.container.fullscreen();
44458
+ this.core.activeContainer.fullscreen();
44450
44459
  this.core.toggleFullscreen();
44451
44460
  this.resetUserKeepVisible();
44452
44461
  }
@@ -44458,6 +44467,7 @@ class MediaControl extends UICorePlugin {
44458
44467
  this.changeTogglePlay();
44459
44468
  this.bindContainerEvents();
44460
44469
  this.updateSettings();
44470
+ // TODO remove
44461
44471
  this.core.activeContainer.trigger(Events$1.CONTAINER_PLAYBACKDVRSTATECHANGED, this.core.activeContainer.isDvrInUse());
44462
44472
  // TODO test
44463
44473
  if (this.core.activeContainer.mediaControlDisabled) {
@@ -44528,9 +44538,9 @@ class MediaControl extends UICorePlugin {
44528
44538
  }
44529
44539
  // default to 100%
44530
44540
  this.currentSeekBarPercentage = 100;
44531
- if (this.container &&
44532
- (this.container.getPlaybackType() !== Playback.LIVE ||
44533
- this.container.isDvrInUse())) {
44541
+ if (this.core.activeContainer &&
44542
+ (this.core.activeContainer.getPlaybackType() !== Playback.LIVE ||
44543
+ this.core.activeContainer.isDvrInUse())) {
44534
44544
  this.currentSeekBarPercentage =
44535
44545
  (this.currentPositionValue / this.currentDurationValue) * 100;
44536
44546
  }
@@ -44557,16 +44567,10 @@ class MediaControl extends UICorePlugin {
44557
44567
  const offsetX = MediaControl.getPageX(event) - this.$seekBarContainer.offset().left;
44558
44568
  let pos = (offsetX / this.$seekBarContainer.width()) * 100;
44559
44569
  pos = Math.min(100, Math.max(pos, 0));
44560
- this.container && this.container.seekPercentage(pos);
44570
+ this.core.activeContainer && this.core.activeContainer.seekPercentage(pos);
44561
44571
  this.setSeekPercentage(pos);
44562
44572
  return false;
44563
44573
  }
44564
- setKeepVisible() {
44565
- this.keepVisible = true;
44566
- }
44567
- resetKeepVisible() {
44568
- this.keepVisible = false;
44569
- }
44570
44574
  setUserKeepVisible() {
44571
44575
  this.userKeepVisible = true;
44572
44576
  }
@@ -44644,7 +44648,12 @@ class MediaControl extends UICorePlugin {
44644
44648
  default: [],
44645
44649
  right: [],
44646
44650
  }, this.core.activeContainer.settings);
44651
+ // TODO make order controlled via CSS
44647
44652
  newSettings.left = orderByOrderPattern([...newSettings.left, 'clipsText', 'volume'], LEFT_ORDER);
44653
+ if (this.core.activePlayback.getPlaybackType() === Playback.LIVE &&
44654
+ this.core.activePlayback.dvrEnabled) {
44655
+ newSettings.left.push('dvr');
44656
+ }
44648
44657
  // actual order of the items appear rendered is controlled by CSS
44649
44658
  newSettings.right = [
44650
44659
  'fullscreen',
@@ -44666,17 +44675,18 @@ class MediaControl extends UICorePlugin {
44666
44675
  }
44667
44676
  removeArrayItem(newSettings.default, 'hd-indicator');
44668
44677
  removeArrayItem(newSettings.left, 'hd-indicator');
44678
+ // TODO get from container's settings
44669
44679
  if (this.core.activePlayback.name === 'html5_video') {
44670
44680
  newSettings.seekEnabled = this.isSeekEnabledForHtml5Playback();
44671
44681
  }
44672
- const settingsChanged = JSON.stringify(this.settings) !== JSON.stringify(newSettings);
44682
+ const settingsChanged = serializeSettings(this.settings) !== serializeSettings(newSettings);
44673
44683
  if (settingsChanged) {
44674
44684
  this.settings = newSettings;
44675
44685
  this.render();
44676
44686
  }
44677
44687
  }
44678
- highDefinitionUpdate(isHD) {
44679
- this.isHD = isHD;
44688
+ onHdUpdate(isHD) {
44689
+ // TODO render?
44680
44690
  }
44681
44691
  createCachedElements() {
44682
44692
  const $layer = this.$el.find('.media-control-layer');
@@ -44739,7 +44749,7 @@ class MediaControl extends UICorePlugin {
44739
44749
  trace(`${T$e} putElement`, { name, panel: !!panel });
44740
44750
  if (panel) {
44741
44751
  const current = panel.find(`[data-${name}]`);
44742
- element.setAttribute(`data-${name}`, "");
44752
+ element.setAttribute(`data-${name}`, '');
44743
44753
  // TODO test
44744
44754
  if (current.length) {
44745
44755
  if (current[0] === element) {
@@ -44753,16 +44763,16 @@ class MediaControl extends UICorePlugin {
44753
44763
  }
44754
44764
  }
44755
44765
  /**
44756
- * Get the right panel area to append custom elements to
44757
- * @returns ZeptoSelector of the right panel element
44766
+ * Toggle the visibility of a media control element
44767
+ * @param name - The name of the media control element
44768
+ * @param show - Whether to show or hide the element
44758
44769
  */
44770
+ toggleElement(name, show) {
44771
+ this.$el.find(`[data-${name}]`).toggle(show);
44772
+ }
44759
44773
  getRightPanel() {
44760
44774
  return this.$el.find('.media-control-right-panel');
44761
44775
  }
44762
- /**
44763
- * Get the left panel area to append custom elements to
44764
- * @returns ZeptoSelector of the left panel element
44765
- */
44766
44776
  getLeftPanel() {
44767
44777
  return this.$el.find('.media-control-left-panel');
44768
44778
  }
@@ -44961,7 +44971,6 @@ class MediaControl extends UICorePlugin {
44961
44971
  this.hideVolumeBar(0);
44962
44972
  }, 0);
44963
44973
  this.parseColors();
44964
- this.highDefinitionUpdate(this.isHD);
44965
44974
  this.core.$el.append(this.el);
44966
44975
  this.rendered = true;
44967
44976
  this.updateVolumeUI();
@@ -45048,10 +45057,27 @@ class MediaControl extends UICorePlugin {
45048
45057
  }
45049
45058
  return null;
45050
45059
  }
45060
+ onDvrStateChanged(dvrInUse) {
45061
+ if (dvrInUse) {
45062
+ this.$el.addClass('dvr');
45063
+ }
45064
+ else {
45065
+ this.$el.removeClass('dvr');
45066
+ }
45067
+ }
45051
45068
  }
45052
45069
  MediaControl.extend = function (properties) {
45053
45070
  return extend(MediaControl, properties);
45054
45071
  };
45072
+ function serializeSettings(s) {
45073
+ return s.left
45074
+ .slice()
45075
+ .sort()
45076
+ .concat(s.right.slice().sort())
45077
+ .concat(s.default.slice().sort())
45078
+ .concat([s.seekEnabled])
45079
+ .join(',');
45080
+ }
45055
45081
 
45056
45082
  const VERSION$5 = '2.19.12';
45057
45083
  const T$d = 'plugins.bottom_gear';
@@ -48275,7 +48301,7 @@ class ContextMenu extends UIContainerPlugin {
48275
48301
  };
48276
48302
  }
48277
48303
 
48278
- const dvrHTML = "<div class=\"live-info\"><%= live %></div>\n<button type=\"button\" class=\"live-button\" aria-label=\"<%= backToLive %>\"><%= backToLive %></button>\n";
48304
+ const dvrHTML = "<div class=\"live-info\" id=\"media-control-live\"><%= i18n.t('live') %></div>\n<button type=\"button\" class=\"live-button\" aria-label=\"<%= i18n.t('back_to_live') %>\" id=\"media-control-back-to-live\"><%= i18n.t('back_to_live') %></button>\n";
48279
48305
 
48280
48306
  const T$b = 'plugins.dvr_controls';
48281
48307
  /**
@@ -48320,7 +48346,6 @@ class DvrControls extends UICorePlugin {
48320
48346
  get attributes() {
48321
48347
  return {
48322
48348
  class: 'dvr-controls',
48323
- 'data-dvr-controls': '',
48324
48349
  };
48325
48350
  }
48326
48351
  /**
@@ -48328,40 +48353,18 @@ class DvrControls extends UICorePlugin {
48328
48353
  */
48329
48354
  bindEvents() {
48330
48355
  this.listenTo(this.core, Events$1.CORE_READY, this.onCoreReady);
48331
- this.listenTo(this.core, Events$1.CORE_OPTIONS_CHANGE, this.render);
48332
48356
  this.listenTo(this.core, Events$1.CORE_ACTIVE_CONTAINER_CHANGED, this.bindContainerEvents);
48333
48357
  }
48334
48358
  onCoreReady() {
48335
48359
  const mediaControl = this.core.getPlugin('media_control');
48336
48360
  assert(mediaControl, 'media_control plugin is required');
48337
- this.listenTo(mediaControl, Events$1.MEDIACONTROL_RENDERED, this.settingsUpdate);
48338
- this.settingsUpdate();
48361
+ this.listenTo(mediaControl, Events$1.MEDIACONTROL_RENDERED, this.render);
48362
+ // MediaControl has been rendered
48363
+ this.render();
48339
48364
  }
48340
48365
  bindContainerEvents() {
48366
+ trace(`${T$b} bindContainerEvents`);
48341
48367
  this.listenToOnce(this.core.activeContainer, Events$1.CONTAINER_TIMEUPDATE, this.render);
48342
- this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PLAYBACKDVRSTATECHANGED, this.onDvrChanged);
48343
- }
48344
- onDvrChanged(dvrInUse) {
48345
- trace(`${T$b} onDvrChanged`, {
48346
- dvrInUse,
48347
- });
48348
- if (this.core.getPlaybackType() !== Playback.LIVE) {
48349
- return;
48350
- }
48351
- this.render();
48352
- const mediaControl = this.core.getPlugin('media_control');
48353
- mediaControl.$el.addClass('live');
48354
- if (dvrInUse) {
48355
- mediaControl.$el
48356
- .addClass('dvr')
48357
- .find(
48358
- // TODO add API, test
48359
- '.media-control-indicator[data-position], .media-control-indicator[data-duration]')
48360
- .hide();
48361
- }
48362
- else {
48363
- mediaControl.$el.removeClass('dvr');
48364
- }
48365
48368
  }
48366
48369
  click() {
48367
48370
  const container = this.core.activeContainer;
@@ -48370,13 +48373,8 @@ class DvrControls extends UICorePlugin {
48370
48373
  }
48371
48374
  container.seek(container.getDuration());
48372
48375
  }
48373
- settingsUpdate() {
48374
- this.core.getPlugin('media_control').$el.removeClass('live');
48375
- this.render();
48376
- }
48377
48376
  shouldRender() {
48378
- const useDvrControls = this.core.options.useDvrControls !== false;
48379
- return useDvrControls && this.core.getPlaybackType() === Playback.LIVE;
48377
+ return this.core.getPlaybackType() === Playback.LIVE;
48380
48378
  }
48381
48379
  /**
48382
48380
  * @internal
@@ -48386,16 +48384,19 @@ class DvrControls extends UICorePlugin {
48386
48384
  dvrEnabled: this.core.activePlayback?.dvrEnabled,
48387
48385
  playbackType: this.core.getPlaybackType(),
48388
48386
  });
48387
+ const mediaControl = this.core.getPlugin('media_control');
48388
+ if (!mediaControl) {
48389
+ return this;
48390
+ }
48389
48391
  if (!this.shouldRender()) {
48390
48392
  return this;
48391
48393
  }
48394
+ mediaControl.toggleElement('duration', false);
48395
+ mediaControl.toggleElement('position', false);
48392
48396
  this.$el.html(DvrControls.template({
48393
- live: this.core.i18n.t('live'),
48394
- backToLive: this.core.i18n.t('back_to_live'),
48397
+ i18n: this.core.i18n,
48395
48398
  }));
48396
- const mediaControl = this.core.getPlugin('media_control');
48397
- mediaControl.$el.addClass('live');
48398
- mediaControl.getLeftPanel().append(this.$el);
48399
+ mediaControl.putElement('dvr', this.el);
48399
48400
  return this;
48400
48401
  }
48401
48402
  }