@gcorevideo/player 2.22.14 → 2.22.15

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
@@ -42219,16 +42219,6 @@ class HlsPlayback extends BasePlayback {
42219
42219
  this.seek(seekTo);
42220
42220
  }
42221
42221
  seek(time) {
42222
- // trace(`${T} seek`, {
42223
- // time,
42224
- // duration: this._duration,
42225
- // startTime: this._startTime,
42226
- // currentTimestamp: this.currentTimestamp,
42227
- // playbackType: this.getPlaybackType(),
42228
- // dvrEnabled: this.dvrEnabled,
42229
- // durationExcludesAfterLiveSyncPoint: this._durationExcludesAfterLiveSyncPoint,
42230
- // minDvrSize: this._minDvrSize,
42231
- // })
42232
42222
  if (time < 0) {
42233
42223
  Log.warn('Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point.');
42234
42224
  time = this.getDuration();
@@ -42380,11 +42370,6 @@ class HlsPlayback extends BasePlayback {
42380
42370
  return;
42381
42371
  }
42382
42372
  this._lastTimeUpdate = update;
42383
- // trace(`${T} _onTimeUpdate`, {
42384
- // current: update.current,
42385
- // total: update.total,
42386
- // firstFragDateTime: update.firstFragDateTime,
42387
- // })
42388
42373
  this.trigger(Events$1.PLAYBACK_TIMEUPDATE, update, this.name);
42389
42374
  }
42390
42375
  _onDurationChange() {
@@ -42655,12 +42640,6 @@ class HlsPlayback extends BasePlayback {
42655
42640
  this.trigger(Events$1.PLAYBACK_LEVEL_SWITCH_END);
42656
42641
  }
42657
42642
  get dvrEnabled() {
42658
- // trace(`${T} dvrEnabled`, {
42659
- // durationExcludesAfterLiveSyncPoint: this._durationExcludesAfterLiveSyncPoint,
42660
- // duration: this._duration,
42661
- // minDvrSize: this._minDvrSize,
42662
- // playbackType: this.getPlaybackType(),
42663
- // })
42664
42643
  // enabled when:
42665
42644
  // - the duration does not include content after hlsjs's live sync point
42666
42645
  // - the playable region duration is longer than the configured duration to enable dvr after
@@ -42949,6 +42928,9 @@ class Player {
42949
42928
  * ```
42950
42929
  */
42951
42930
  attachTo(playerElement) {
42931
+ trace(`${T$h} attachTo`, {
42932
+ player: !!this.player,
42933
+ });
42952
42934
  assert.ok(!this.player, 'Player already initialized');
42953
42935
  assert.ok(playerElement, 'Player container element is required');
42954
42936
  if (this.config.debug === 'all' || this.config.debug === 'clappr') {
@@ -43160,9 +43142,9 @@ class Player {
43160
43142
  trace(`${T$h} initPlayer`, {
43161
43143
  autoPlay: coreOptions.autoPlay,
43162
43144
  sources: coreOptions.sources,
43145
+ player: !!this.player,
43163
43146
  // TODO selected options
43164
43147
  });
43165
- assert.ok(!this.player, 'Player already initialized');
43166
43148
  const player = new Player$1(coreOptions);
43167
43149
  this.player = player;
43168
43150
  this.bindCoreListeners();
@@ -43325,7 +43307,7 @@ class Player {
43325
43307
  }
43326
43308
  }
43327
43309
 
43328
- var version$1 = "2.22.14";
43310
+ var version$1 = "2.22.15";
43329
43311
 
43330
43312
  var packages = {
43331
43313
  "node_modules/@clappr/core": {
@@ -46666,7 +46648,7 @@ class ClapprStats extends ContainerPlugin {
46666
46648
  // Copyright 2014 Globo.com Player authors. All rights reserved.
46667
46649
  // Use of this source code is governed by a BSD-style
46668
46650
  // license that can be found at https://github.com/clappr/clappr-plugins/blob/master/LICENSE.
46669
- const T$d = 'plugins.click_to_pause_custom';
46651
+ const T$d = 'plugins.click_to_pause';
46670
46652
  /**
46671
46653
  * A small `PLUGIN` that toggles the playback state on click over the video container
46672
46654
  * @beta
@@ -46929,18 +46911,18 @@ class ClipsPlugin extends UICorePlugin {
46929
46911
  }
46930
46912
  }
46931
46913
 
46932
- const templateHtml$1 = "<ul class=\"context-menu-list\">\n <% if(options) { %>\n <% for (var i = 0; i < options.length; i++) { %>\n <li class=\"context-menu-list-item <%= options[i].class %>\"\n data-<%= options[i].name %>><%= options[i].label %></li>\n <% } %>\n <% } %>\n</ul>\n";
46914
+ const templateHtml$1 = "<ul class=\"context-menu-list\" role=\"menu\" id=\"context-menu-options\">\n <% for (const item of options) { %>\n <li class=\"context-menu-list-item <%= item.class %>\">\n <button role=\"menuitem\" data-name=\"<%= item.name %>\">\n <% if (iconic) { %>\n <span class=\"context-menu-list-item_icon\"><%= item.icon || '' %></span>\n <% } %>\n <% if (item.labelKey) { %>\n <%= i18n.t(item.labelKey) %>\n <% } else { %>\n <%= item.label %>\n <% } %>\n </button>\n </li>\n <% } %>\n</ul>\n";
46933
46915
 
46934
46916
  /**
46935
46917
  * `PLUGIN` that displays a small context menu when clicked on the player container.
46936
46918
  * @beta
46937
46919
  * @remarks
46938
46920
  * Configuration options - {@link ContextMenuPluginSettings}
46921
+ *
46922
+ * Should not be used together with {@link ClickToPause} plugin
46939
46923
  */
46940
46924
  class ContextMenu extends UIContainerPlugin {
46941
- _label = '';
46942
- _url = '';
46943
- menuOptions = [];
46925
+ open = false;
46944
46926
  /**
46945
46927
  * @internal
46946
46928
  */
@@ -46960,34 +46942,16 @@ class ContextMenu extends UIContainerPlugin {
46960
46942
  return { class: 'context-menu' };
46961
46943
  }
46962
46944
  static template = tmpl(templateHtml$1);
46963
- get label() {
46964
- return this._label || 'Gcore player ver. ' + version().gplayer;
46965
- }
46966
- get url() {
46967
- return this._url || 'https://gcore.com/';
46968
- }
46969
- get exposeVersion() {
46970
- return {
46971
- label: this.label,
46972
- name: 'version',
46973
- };
46974
- }
46975
46945
  /**
46976
46946
  * @internal
46977
46947
  */
46978
46948
  get events() {
46979
46949
  return {
46980
- 'click [data-version]': 'onOpenMainPage',
46950
+ 'click [role="menuitem"]': 'runAction',
46981
46951
  };
46982
46952
  }
46983
46953
  constructor(container) {
46984
46954
  super(container);
46985
- if (this.options.contextMenu && this.options.contextMenu.label) {
46986
- this._label = this.options.contextMenu.label;
46987
- }
46988
- if (this.options.contextMenu && this.options.contextMenu.url) {
46989
- this._url = this.options.contextMenu.url;
46990
- }
46991
46955
  this.render();
46992
46956
  $('body').on('click', this.hideOnBodyClick);
46993
46957
  }
@@ -46995,8 +46959,8 @@ class ContextMenu extends UIContainerPlugin {
46995
46959
  * @internal
46996
46960
  */
46997
46961
  bindEvents() {
46998
- this.listenTo(this.container, Events$1.CONTAINER_CONTEXTMENU, this.toggleContextMenu);
46999
- this.listenTo(this.container, Events$1.CONTAINER_CLICK, this.hide);
46962
+ this.listenTo(this.container, Events$1.CONTAINER_CONTEXTMENU, this.onContextMenu);
46963
+ this.listenTo(this.container, Events$1.CONTAINER_CLICK, this.onContainerClick);
47000
46964
  }
47001
46965
  /**
47002
46966
  * @internal
@@ -47005,34 +46969,55 @@ class ContextMenu extends UIContainerPlugin {
47005
46969
  $('body').off('click', this.hideOnBodyClick);
47006
46970
  return super.destroy();
47007
46971
  }
47008
- toggleContextMenu(event) {
46972
+ onContainerClick() {
46973
+ this.hide();
46974
+ }
46975
+ onContextMenu(event) {
46976
+ if (!this.options.contextMenu?.options?.length) {
46977
+ return;
46978
+ }
47009
46979
  event.preventDefault();
46980
+ event.stopPropagation();
47010
46981
  const offset = this.container?.$el.offset();
47011
46982
  this.show(event.pageY - offset.top, event.pageX - offset.left);
47012
46983
  }
47013
46984
  show(top, left) {
47014
- this.hide();
47015
- if (this.options.contextMenu &&
47016
- this.options.contextMenu.preventShowContextMenu) {
47017
- return;
47018
- }
46985
+ this.open = true;
47019
46986
  this.$el.css({ top, left });
47020
46987
  this.$el.show();
47021
46988
  }
47022
46989
  hide() {
46990
+ this.open = false;
47023
46991
  this.$el.hide();
47024
46992
  }
47025
- onOpenMainPage() {
47026
- window.open(this.url, '_blank');
46993
+ runAction(event) {
46994
+ event.preventDefault();
46995
+ event.stopPropagation();
46996
+ const itemName = event.currentTarget.dataset.name;
46997
+ if (!itemName) {
46998
+ return;
46999
+ }
47000
+ const item = this.options.contextMenu?.options.find((option) => option.name === itemName);
47001
+ if (item?.handler) {
47002
+ item.handler();
47003
+ }
47004
+ this.hide();
47027
47005
  }
47028
47006
  /**
47029
47007
  * @internal
47030
47008
  */
47031
47009
  render() {
47032
- this.menuOptions = [this.exposeVersion];
47033
- this.$el.html(ContextMenu.template({ options: this.menuOptions }));
47010
+ if (!this.options.contextMenu?.options?.length) {
47011
+ return this;
47012
+ }
47013
+ const options = this.options.contextMenu.options;
47014
+ this.$el.html(ContextMenu.template({
47015
+ options,
47016
+ i18n: this.container.i18n,
47017
+ iconic: options.some((option) => option.icon),
47018
+ }));
47034
47019
  this.container.$el.append(this.$el); // TODO append to the container, turn into a container plugin
47035
- this.hide();
47020
+ this.$el.hide();
47036
47021
  return this;
47037
47022
  }
47038
47023
  hideOnBodyClick = () => {