@gcorevideo/player 2.22.13 → 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.
Files changed (39) hide show
  1. package/assets/bottom-gear/gear.scss +20 -13
  2. package/assets/clappr-nerd-stats/button.ejs +2 -2
  3. package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +0 -43
  4. package/assets/context-menu/context_menu.ejs +14 -6
  5. package/assets/context-menu/context_menu.scss +18 -4
  6. package/assets/level-selector/button.ejs +3 -3
  7. package/assets/level-selector/style.scss +0 -5
  8. package/assets/playback-rate/button.ejs +2 -2
  9. package/dist/core.js +5 -2
  10. package/dist/index.css +815 -834
  11. package/dist/index.js +79 -78
  12. package/dist/plugins/index.css +669 -688
  13. package/dist/plugins/index.js +73 -99
  14. package/lib/Player.d.ts.map +1 -1
  15. package/lib/Player.js +4 -1
  16. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
  17. package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
  18. package/lib/plugins/context-menu/ContextMenu.d.ts +33 -12
  19. package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -1
  20. package/lib/plugins/context-menu/ContextMenu.js +40 -37
  21. package/lib/plugins/media-control/MediaControl.d.ts +4 -1
  22. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  23. package/lib/plugins/media-control/MediaControl.js +30 -14
  24. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  25. package/lib/plugins/playback-rate/PlaybackRate.js +1 -22
  26. package/package.json +1 -1
  27. package/src/Player.ts +4 -3
  28. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +0 -1
  29. package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
  30. package/src/plugins/context-menu/ContextMenu.ts +72 -56
  31. package/src/plugins/level-selector/__tests__/__snapshots__/QualityLevels.test.ts.snap +3 -3
  32. package/src/plugins/media-control/MediaControl.ts +36 -15
  33. package/src/plugins/media-control/__tests__/MediaControl.test.ts +101 -32
  34. package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +20 -20
  35. package/src/plugins/playback-rate/PlaybackRate.ts +1 -24
  36. package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +2 -1
  37. package/tsconfig.tsbuildinfo +1 -1
  38. package/assets/clappr-nerd-stats/options-list.ejs +0 -9
  39. package/assets/clappr-nerd-stats/settings.ejs +0 -12
package/dist/index.js CHANGED
@@ -42928,6 +42928,9 @@ class Player {
42928
42928
  * ```
42929
42929
  */
42930
42930
  attachTo(playerElement) {
42931
+ trace(`${T$h} attachTo`, {
42932
+ player: !!this.player,
42933
+ });
42931
42934
  assert.ok(!this.player, 'Player already initialized');
42932
42935
  assert.ok(playerElement, 'Player container element is required');
42933
42936
  if (this.config.debug === 'all' || this.config.debug === 'clappr') {
@@ -43139,9 +43142,9 @@ class Player {
43139
43142
  trace(`${T$h} initPlayer`, {
43140
43143
  autoPlay: coreOptions.autoPlay,
43141
43144
  sources: coreOptions.sources,
43145
+ player: !!this.player,
43142
43146
  // TODO selected options
43143
43147
  });
43144
- assert.ok(!this.player, 'Player already initialized');
43145
43148
  const player = new Player$1(coreOptions);
43146
43149
  this.player = player;
43147
43150
  this.bindCoreListeners();
@@ -43304,7 +43307,7 @@ class Player {
43304
43307
  }
43305
43308
  }
43306
43309
 
43307
- var version$1 = "2.22.13";
43310
+ var version$1 = "2.22.15";
43308
43311
 
43309
43312
  var packages = {
43310
43313
  "node_modules/@clappr/core": {
@@ -45952,7 +45955,7 @@ function rankConnectionSpeed(dlSpeed) {
45952
45955
 
45953
45956
  const pluginHtml$4 = "<% general = metrics.general %>\n<% counters = metrics.counters %>\n<% timers = metrics.timers %>\n<% extra = metrics.extra %>\n<% custom = metrics.custom %>\n\n<div class=\"stats-box\">\n <div class=\"stats-box-top\">\n <a class=\"close-button gplayer-lite-btn\" data-close-button>\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\">\n <g clip-path=\"url(#clip0_184_1489)\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\n d=\"M7.41376 6.00013L13.7068 -0.292872C14.0978 -0.683872 14.0978 -1.31587 13.7068 -1.70687C13.3158 -2.09787 12.6838 -2.09787 12.2928 -1.70687L5.99976 4.58613L-0.293238 -1.70687C-0.684238 -2.09787 -1.31624 -2.09787 -1.70724 -1.70687C-2.09824 -1.31587 -2.09824 -0.683872 -1.70724 -0.292872L4.58576 6.00013L-1.70724 12.2931C-2.09824 12.6841 -2.09824 13.3161 -1.70724 13.7071C-1.51224 13.9021 -1.25624 14.0001 -1.00024 14.0001C-0.744238 14.0001 -0.488238 13.9021 -0.293238 13.7071L5.99976 7.41413L12.2928 13.7071C12.4878 13.9021 12.7438 14.0001 12.9998 14.0001C13.2558 14.0001 13.5118 13.9021 13.7068 13.7071C14.0978 13.3161 14.0978 12.6841 13.7068 12.2931L7.41376 6.00013Z\"\n fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_184_1489\">\n <rect width=\"12\" height=\"12\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </a>\n </div>\n <div class=\"stats-box-main\">\n <ul>\n <li class=\"title\"><span>General</span></li>\n <li>\n Display resolution:\n <div><span><%= general.displayResolution %></span></div>\n </li>\n <li>\n Volume:\n <div><span><%= general.volume %></span></div>\n </li>\n <li>\n Connection speed:\n <div><span id=\"dlText\"><%= custom.connectionSpeed %></span> Mbps</div>\n </li>\n <li class=\"canvas-wrapper\">\n <canvas id=\"speedTestCanvas\" width=\"190\" height=\"20\"></canvas>\n </li>\n <li>\n Ping:\n <div><span id=\"pingText\"><%= custom.ping %></span> ms</div>\n </li>\n <li>\n Jitter:\n <div><span id=\"jitterText\"><%= custom.jitter %></span> ms</div>\n </li>\n </ul>\n\n <ul>\n <li class=\"title\"><span>Counters</span></li>\n <li>\n Plays:\n <div><span><%= counters.play %></span></div>\n </li>\n <li>\n Pauses:\n <div><span><%= counters.pause %></span></div>\n </li>\n <li>\n Errors:\n <div><span><%= counters.error %></span></div>\n </li>\n <li>\n Bufferings:\n <div><span><%= counters.buffering %></span></div>\n </li>\n <li>\n Decoded frames:\n <div><span><%= counters.decodedFrames %></span></div>\n </li>\n <li>\n Dropped frames:\n <div><span><%= counters.droppedFrames %></span></div>\n </li>\n <li>\n Frames per second:\n <div><span><%= counters.fps %></span></div>\n </li>\n <li>\n Bitrate changes:\n <div><span><%= counters.changeLevel %></span></div>\n </li>\n <li>\n Seeks:\n <div><span><%= counters.seek %></span></div>\n </li>\n <li>\n Fullscreen:\n <div><span><%= counters.fullscreen %></span></div>\n </li>\n <li>\n DVR seeks:\n <div><span><%= counters.dvrUsage %></span></div>\n </li>\n </ul>\n\n <ul>\n <li class=\"title\"><span>Timers</span></li>\n <li>\n Startup time:\n <div><span><%= timers.startup %></span></div>\n </li>\n <li>\n Watching time:\n <div><span><%= timers.watch %></span></div>\n </li>\n <li>\n Pause time:\n <div><span><%= timers.pause %></span></div>\n </li>\n <li>\n Buffering time:\n <div><span><%= timers.buffering %></span></div>\n </li>\n <li>\n Session time:\n <div><span><%= timers.session %></span></div>\n </li>\n <!-- <li>-->\n <!-- Latency:-->\n <!-- <div><span><%= timers.latency %></span></div>-->\n <!-- </li>-->\n </ul>\n\n <ul>\n <li class=\"title\"><span>Extra</span></li>\n <li>\n Playback:\n <div><span><%= extra.playbackName %></span></div>\n </li>\n <li>\n Playback type:\n <div><span><%= extra.playbackType %></span></div>\n </li>\n <li>\n Buffer size:\n <div><span><%= extra.buffersize %></span></div>\n </li>\n <li>\n Video duration:\n <div><span><%= extra.duration %></span></div>\n </li>\n <li>\n Current time:\n <div><span><%= extra.currentTime %></span></div>\n </li>\n <li>\n Bitrate weighted mean:\n <div><span><%= extra.bitrateWeightedMean %></span></div>\n </li>\n <li>\n Bitrate most used:\n <div><span><%= extra.bitrateMostUsed %></span></div>\n </li>\n <li>\n % Watched:\n <div><span><%= extra.watchedPercentage %></span></div>\n </li>\n <li>\n % Buffering:\n <div><span><%= extra.bufferingPercentage %></span></div>\n </li>\n </ul>\n </div>\n <div class=\"speedtest-summary\">\n <div class=\"speedtest-summary-header\">Your internet quality summary</div>\n <div class=\"speedtest-summary-block\">\n <div class=\"speedtest-summary-subblock\">\n <div class=\"speedtest-summary-subblock-content\">\n <div class=\"speedtest-quality\">\n <div class=\"speedtest-quality-header\">VOD: <%= custom.vodQuality %></div>\n <div class=\"speedtest-quality-content\" data-streaming-type=\"vod\">\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"speedtest-summary-subblock\">\n <div class=\"speedtest-summary-subblock-content\">\n <div class=\"speedtest-quality\">\n <div class=\"speedtest-quality-header\">Live: <%= custom.liveQuality %></div>\n <div class=\"speedtest-quality-content\" data-streaming-type=\"live\">\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n <div class=\"speedtest-quality-content-item\"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"speedtest-footer\">\n <!-- <a class=\"speedtest-footer-about-link\" href=\"\" target=\"_blank\">I am not a nerd, what's this all about?</a>-->\n <button class=\"gplayer-lite-btn speedtest-btn speedtest-footer-refresh\" data-refresh-button type=\"button\">\n <svg width=\"12\" height=\"10\" viewBox=\"0 0 12 10\" fill=\"none\">\n <path\n d=\"M6.03968 0.124998C3.64268 0.124998 1.67268 1.9565 1.48068 4.2915H1.00018C0.925833 4.29146 0.853156 4.31353 0.791378 4.35489C0.729601 4.39625 0.681511 4.45503 0.653218 4.52378C0.624925 4.59253 0.617705 4.66814 0.632476 4.74101C0.647248 4.81387 0.683343 4.88069 0.736177 4.933L1.57618 5.766C1.64641 5.83561 1.74129 5.87467 1.84018 5.87467C1.93906 5.87467 2.03395 5.83561 2.10418 5.766L2.94418 4.933C2.99701 4.88069 3.03311 4.81387 3.04788 4.74101C3.06265 4.66814 3.05543 4.59253 3.02714 4.52378C2.99884 4.45503 2.95075 4.39625 2.88898 4.35489C2.8272 4.31353 2.75452 4.29146 2.68018 4.2915H2.23368C2.42368 2.376 4.05268 0.874998 6.03968 0.874998C6.6948 0.873639 7.33932 1.04039 7.91158 1.35931C8.48384 1.67822 8.9647 2.13863 9.30818 2.6965C9.33331 2.73978 9.36686 2.7776 9.40684 2.80771C9.44682 2.83783 9.49243 2.85963 9.54097 2.87184C9.58951 2.88405 9.64001 2.88643 9.68948 2.87881C9.73895 2.8712 9.7864 2.85377 9.82902 2.82753C9.87165 2.80129 9.90859 2.76679 9.93767 2.72605C9.96675 2.68531 9.98739 2.63916 9.99835 2.59032C10.0093 2.54148 10.0104 2.49095 10.0015 2.44168C9.99264 2.39242 9.974 2.34544 9.94668 2.3035C9.53615 1.63664 8.96146 1.08621 8.27752 0.704805C7.59359 0.323402 6.82277 0.123774 6.03968 0.124998ZM10.4207 4.2335C10.3505 4.16419 10.2558 4.12532 10.1572 4.12532C10.0585 4.12532 9.96386 4.16419 9.89368 4.2335L9.05018 5.0665C8.9972 5.11874 8.96096 5.18557 8.94608 5.25847C8.93119 5.33137 8.93833 5.40705 8.96658 5.47588C8.99483 5.54472 9.04292 5.60359 9.10473 5.64501C9.16654 5.68644 9.23927 5.70853 9.31368 5.7085H9.76318C9.57218 7.6235 7.93768 9.125 5.94118 9.125C5.28399 9.12683 4.63729 8.96035 4.06269 8.64141C3.48808 8.32247 3.00473 7.86169 2.65868 7.303C2.63281 7.26107 2.59893 7.22465 2.55899 7.19582C2.51904 7.16699 2.47381 7.14631 2.42587 7.13495C2.37793 7.1236 2.32823 7.1218 2.27959 7.12966C2.23096 7.13752 2.18435 7.15488 2.14243 7.18075C2.05776 7.233 1.99731 7.31674 1.97438 7.41355C1.95146 7.51037 1.96793 7.61233 2.02018 7.697C2.43345 8.36457 3.01076 8.91521 3.69713 9.29647C4.38349 9.67772 5.15604 9.87689 5.94118 9.875C8.34518 9.875 10.3237 8.045 10.5162 5.7085H11.0002C11.0746 5.70853 11.1473 5.68644 11.2091 5.64501C11.2709 5.60359 11.319 5.54472 11.3473 5.47588C11.3755 5.40705 11.3827 5.33137 11.3678 5.25847C11.3529 5.18557 11.3167 5.11874 11.2637 5.0665L10.4207 4.2335Z\"\n fill=\"white\"/>\n </svg>\n Refresh\n </button>\n </div>\n</div>\n";
45954
45957
 
45955
- const buttonHtml$3 = "<button class='nerd-button gplayer-lite-btn gcore-skin-text-color gear-option' id=\"nerd-stats-button\">\n <span class=\"stats-icon\"><%= icon %></span>\n <span><%= i18n.t('statistics') %></span>\n</button>\n";
45958
+ const buttonHtml$3 = "<button class='nerd-button gplayer-lite-btn gcore-skin-text-color gear-option' id=\"nerd-stats-button\">\n <span class=\"gear-option_icon\"><%= icon %></span>\n <span class=\"gear-option_label\"><%= i18n.t('statistics') %></span>\n</button>\n";
45956
45959
 
45957
45960
  const statsIcon = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9.16675 14.1667H10.8334V9.16666H9.16675V14.1667ZM10.0001 7.5C10.2362 7.5 10.4342 7.42 10.5942 7.26C10.7542 7.1 10.834 6.90222 10.8334 6.66666C10.8334 6.43055 10.7534 6.2325 10.5934 6.0725C10.4334 5.9125 10.2356 5.83278 10.0001 5.83333C9.76397 5.83333 9.56591 5.91333 9.40591 6.07333C9.24591 6.23333 9.16619 6.43111 9.16675 6.66666C9.16675 6.90278 9.24675 7.10083 9.40675 7.26083C9.56675 7.42083 9.76453 7.50055 10.0001 7.5ZM10.0001 18.3333C8.8473 18.3333 7.76397 18.1144 6.75008 17.6767C5.73619 17.2389 4.85425 16.6453 4.10425 15.8958C3.35425 15.1458 2.76064 14.2639 2.32341 13.25C1.88619 12.2361 1.6673 11.1528 1.66675 10C1.66675 8.84722 1.88564 7.76389 2.32341 6.75C2.76119 5.73611 3.3548 4.85416 4.10425 4.10416C4.85425 3.35416 5.73619 2.76055 6.75008 2.32333C7.76397 1.88611 8.8473 1.66722 10.0001 1.66666C11.1529 1.66666 12.2362 1.88555 13.2501 2.32333C14.264 2.76111 15.1459 3.35472 15.8959 4.10416C16.6459 4.85416 17.2398 5.73611 17.6776 6.75C18.1154 7.76389 18.334 8.84722 18.3334 10C18.3334 11.1528 18.1145 12.2361 17.6767 13.25C17.239 14.2639 16.6454 15.1458 15.8959 15.8958C15.1459 16.6458 14.264 17.2397 13.2501 17.6775C12.2362 18.1153 11.1529 18.3339 10.0001 18.3333ZM10.0001 16.6667C11.8612 16.6667 13.4376 16.0208 14.7292 14.7292C16.0209 13.4375 16.6667 11.8611 16.6667 10C16.6667 8.13889 16.0209 6.5625 14.7292 5.27083C13.4376 3.97916 11.8612 3.33333 10.0001 3.33333C8.13897 3.33333 6.56258 3.97916 5.27091 5.27083C3.97925 6.5625 3.33341 8.13889 3.33341 10C3.33341 11.8611 3.97925 13.4375 5.27091 14.7292C6.56258 16.0208 8.13897 16.6667 10.0001 16.6667Z\" fill=\"#FFFFFF\"/>\n</svg>\n";
45958
45961
 
@@ -46645,7 +46648,7 @@ class ClapprStats extends ContainerPlugin {
46645
46648
  // Copyright 2014 Globo.com Player authors. All rights reserved.
46646
46649
  // Use of this source code is governed by a BSD-style
46647
46650
  // license that can be found at https://github.com/clappr/clappr-plugins/blob/master/LICENSE.
46648
- const T$d = 'plugins.click_to_pause_custom';
46651
+ const T$d = 'plugins.click_to_pause';
46649
46652
  /**
46650
46653
  * A small `PLUGIN` that toggles the playback state on click over the video container
46651
46654
  * @beta
@@ -46908,18 +46911,18 @@ class ClipsPlugin extends UICorePlugin {
46908
46911
  }
46909
46912
  }
46910
46913
 
46911
- 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";
46912
46915
 
46913
46916
  /**
46914
46917
  * `PLUGIN` that displays a small context menu when clicked on the player container.
46915
46918
  * @beta
46916
46919
  * @remarks
46917
46920
  * Configuration options - {@link ContextMenuPluginSettings}
46921
+ *
46922
+ * Should not be used together with {@link ClickToPause} plugin
46918
46923
  */
46919
46924
  class ContextMenu extends UIContainerPlugin {
46920
- _label = '';
46921
- _url = '';
46922
- menuOptions = [];
46925
+ open = false;
46923
46926
  /**
46924
46927
  * @internal
46925
46928
  */
@@ -46939,34 +46942,16 @@ class ContextMenu extends UIContainerPlugin {
46939
46942
  return { class: 'context-menu' };
46940
46943
  }
46941
46944
  static template = tmpl(templateHtml$1);
46942
- get label() {
46943
- return this._label || 'Gcore player ver. ' + version().gplayer;
46944
- }
46945
- get url() {
46946
- return this._url || 'https://gcore.com/';
46947
- }
46948
- get exposeVersion() {
46949
- return {
46950
- label: this.label,
46951
- name: 'version',
46952
- };
46953
- }
46954
46945
  /**
46955
46946
  * @internal
46956
46947
  */
46957
46948
  get events() {
46958
46949
  return {
46959
- 'click [data-version]': 'onOpenMainPage',
46950
+ 'click [role="menuitem"]': 'runAction',
46960
46951
  };
46961
46952
  }
46962
46953
  constructor(container) {
46963
46954
  super(container);
46964
- if (this.options.contextMenu && this.options.contextMenu.label) {
46965
- this._label = this.options.contextMenu.label;
46966
- }
46967
- if (this.options.contextMenu && this.options.contextMenu.url) {
46968
- this._url = this.options.contextMenu.url;
46969
- }
46970
46955
  this.render();
46971
46956
  $('body').on('click', this.hideOnBodyClick);
46972
46957
  }
@@ -46974,8 +46959,8 @@ class ContextMenu extends UIContainerPlugin {
46974
46959
  * @internal
46975
46960
  */
46976
46961
  bindEvents() {
46977
- this.listenTo(this.container, Events$1.CONTAINER_CONTEXTMENU, this.toggleContextMenu);
46978
- 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);
46979
46964
  }
46980
46965
  /**
46981
46966
  * @internal
@@ -46984,34 +46969,55 @@ class ContextMenu extends UIContainerPlugin {
46984
46969
  $('body').off('click', this.hideOnBodyClick);
46985
46970
  return super.destroy();
46986
46971
  }
46987
- toggleContextMenu(event) {
46972
+ onContainerClick() {
46973
+ this.hide();
46974
+ }
46975
+ onContextMenu(event) {
46976
+ if (!this.options.contextMenu?.options?.length) {
46977
+ return;
46978
+ }
46988
46979
  event.preventDefault();
46980
+ event.stopPropagation();
46989
46981
  const offset = this.container?.$el.offset();
46990
46982
  this.show(event.pageY - offset.top, event.pageX - offset.left);
46991
46983
  }
46992
46984
  show(top, left) {
46993
- this.hide();
46994
- if (this.options.contextMenu &&
46995
- this.options.contextMenu.preventShowContextMenu) {
46996
- return;
46997
- }
46985
+ this.open = true;
46998
46986
  this.$el.css({ top, left });
46999
46987
  this.$el.show();
47000
46988
  }
47001
46989
  hide() {
46990
+ this.open = false;
47002
46991
  this.$el.hide();
47003
46992
  }
47004
- onOpenMainPage() {
47005
- 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();
47006
47005
  }
47007
47006
  /**
47008
47007
  * @internal
47009
47008
  */
47010
47009
  render() {
47011
- this.menuOptions = [this.exposeVersion];
47012
- 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
+ }));
47013
47019
  this.container.$el.append(this.$el); // TODO append to the container, turn into a container plugin
47014
- this.hide();
47020
+ this.$el.hide();
47015
47021
  return this;
47016
47022
  }
47017
47023
  hideOnBodyClick = () => {
@@ -47990,8 +47996,10 @@ class MediaControl extends UICorePlugin {
47990
47996
  kibo;
47991
47997
  lastMouseX = 0;
47992
47998
  lastMouseY = 0;
47993
- needsUpdate = false;
47999
+ metadataLoaded = false;
48000
+ hasUpdate = false;
47994
48001
  persistConfig;
48002
+ renderTimerId = null;
47995
48003
  rendered = false;
47996
48004
  settings = INITIAL_SETTINGS;
47997
48005
  userDisabled = false;
@@ -48177,8 +48185,10 @@ class MediaControl extends UICorePlugin {
48177
48185
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_ENDED, this.ended);
48178
48186
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_VOLUME, this.onVolumeChanged);
48179
48187
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_OPTIONS_CHANGE, this.setInitialVolume);
48180
- // wait until the metadata has loaded and then check if fullscreen on video tag is supported
48181
- this.listenToOnce(this.core.activeContainer, Events$1.CONTAINER_LOADEDMETADATA, this.onLoadedMetadata);
48188
+ this.listenTo(this.core.activeContainer, Events$1.CONTAINER_LOADEDMETADATA, this.onLoadedMetadata);
48189
+ this.listenTo(this.core, Events$1.CONTAINER_DESTROYED, () => {
48190
+ this.cancelRenderTimer();
48191
+ });
48182
48192
  }
48183
48193
  /**
48184
48194
  * Hides the media control UI
@@ -48221,13 +48231,17 @@ class MediaControl extends UICorePlugin {
48221
48231
  // TODO sort out, use single utility function
48222
48232
  this.fullScreenOnVideoTagSupported = true;
48223
48233
  }
48224
- this.updateSettings();
48225
- if (this.core.activeContainer.getPlaybackType() === Playback.LIVE) {
48226
- this.$el.addClass('live');
48227
- }
48228
- else {
48229
- this.$el.removeClass('live');
48230
- }
48234
+ this.renderTimerId = setTimeout(() => {
48235
+ this.renderTimerId = null;
48236
+ this.metadataLoaded = true;
48237
+ this.render();
48238
+ if (this.core.activeContainer.getPlaybackType() === Playback.LIVE) {
48239
+ this.$el.addClass('live');
48240
+ }
48241
+ else {
48242
+ this.$el.removeClass('live');
48243
+ }
48244
+ }, 25);
48231
48245
  }
48232
48246
  updateVolumeUI() {
48233
48247
  // this will be called after a render
@@ -48451,6 +48465,7 @@ class MediaControl extends UICorePlugin {
48451
48465
  }
48452
48466
  onActiveContainerChanged() {
48453
48467
  this.fullScreenOnVideoTagSupported = false;
48468
+ this.metadataLoaded = false;
48454
48469
  // set the new container to match the volume of the last one
48455
48470
  this.setInitialVolume();
48456
48471
  this.changeTogglePlay();
@@ -48672,7 +48687,7 @@ class MediaControl extends UICorePlugin {
48672
48687
  const settingsChanged = serializeSettings(this.settings) !== serializeSettings(newSettings);
48673
48688
  if (settingsChanged) {
48674
48689
  this.settings = newSettings;
48675
- this.needsUpdate = true;
48690
+ this.hasUpdate = true;
48676
48691
  this.render();
48677
48692
  }
48678
48693
  }
@@ -48901,6 +48916,7 @@ class MediaControl extends UICorePlugin {
48901
48916
  * @internal
48902
48917
  */
48903
48918
  destroy() {
48919
+ this.cancelRenderTimer();
48904
48920
  $(document).unbind('mouseup', this.stopDrag);
48905
48921
  $(document).unbind('mousemove', this.updateDrag);
48906
48922
  $(document).unbind('touchend', this.stopDrag);
@@ -48908,6 +48924,12 @@ class MediaControl extends UICorePlugin {
48908
48924
  this.unbindKeyEvents();
48909
48925
  return super.destroy();
48910
48926
  }
48927
+ cancelRenderTimer() {
48928
+ if (this.renderTimerId) {
48929
+ clearTimeout(this.renderTimerId);
48930
+ this.renderTimerId = null;
48931
+ }
48932
+ }
48911
48933
  configure() {
48912
48934
  this.trigger(Events$1.MEDIACONTROL_OPTIONS_CHANGE);
48913
48935
  }
@@ -48915,8 +48937,8 @@ class MediaControl extends UICorePlugin {
48915
48937
  * @internal
48916
48938
  */
48917
48939
  render() {
48918
- trace(`${T$a} render`, { needsUpdate: this.needsUpdate });
48919
- if (!this.needsUpdate) {
48940
+ trace(`${T$a} render`, { needsUpdate: this.hasUpdate, metadataLoaded: this.metadataLoaded });
48941
+ if (!this.hasUpdate || !this.metadataLoaded) {
48920
48942
  return this;
48921
48943
  }
48922
48944
  const timeout = this.options.hideMediaControlDelay || 2000;
@@ -48966,7 +48988,7 @@ class MediaControl extends UICorePlugin {
48966
48988
  this.core.$el.append(this.el);
48967
48989
  this.rendered = true;
48968
48990
  this.updateVolumeUI();
48969
- this.needsUpdate = false;
48991
+ this.hasUpdate = false;
48970
48992
  // TODO setTimeout?
48971
48993
  this.trigger(Events$1.MEDIACONTROL_RENDERED);
48972
48994
  return this;
@@ -49541,7 +49563,7 @@ class PictureInPicture extends UICorePlugin {
49541
49563
  }
49542
49564
  }
49543
49565
 
49544
- const buttonHtml$1 = "<button class='gplayer-lite-btn gcore-skin-text-color gear-option' id=\"playback-rate-button\">\n <span class=\"gear-option_speed-icon\"><%= speedIcon %></span>\n <span class=\"gear-option_label\"><%= i18n.t('playback_rate') %></span>\n <span class=\"gear-option_arrow-right-icon\"><%= arrowRightIcon %></span>\n <span class='gear-option_value'><%= title %></span>\n</button>\n";
49566
+ const buttonHtml$1 = "<button class='gplayer-lite-btn gcore-skin-text-color gear-option' id=\"playback-rate-button\">\n <span class=\"gear-option_speed-icon gear-option_icon\"><%= speedIcon %></span>\n <span class=\"gear-option_label\"><%= i18n.t('playback_rate') %></span>\n <span class='gear-option_value'><%= title %></span>\n <span class=\"gear-option_arrow-right-icon\"><%= arrowRightIcon %></span>\n</button>\n";
49545
49567
 
49546
49568
  const listHtml$1 = "<button class=\"gplayer-lite-btn go-back gcore-skin-text-color\" id=\"playback-rate-back-button\">\n <span class=\"arrow-left-icon\"><%= arrowLeftIcon %></span>\n <%= i18n.t('playback_rate') %>\n</button>\n<ul class=\"gear-sub-menu\" id=\"playback-rate-menu\">\n <% for (const item of playbackRates) { %>\n <li<%= item.value === current ? ' class=\"current\"' : '' %>>\n <a href=\"#\" class=\"gear-sub-menu_btn gcore-skin-text-color<%= item.value === current ? ' gcore-skin-active' : '' %>\" data-rate=\"<%= item.value %>\">\n <span class=\"check-icon\"><%= checkIcon %></span>\n <%= item.label %>\n </a>\n </li>\n <% } %>\n</ul>";
49547
49569
 
@@ -49600,7 +49622,6 @@ class PlaybackRate extends UICorePlugin {
49600
49622
  // private prevSelectedRate: string | undefined
49601
49623
  selectedRate = DEFAULT_PLAYBACK_RATE;
49602
49624
  metadataLoaded = false;
49603
- // private playbackSettingsUpdateReceived = false
49604
49625
  mountTimerId = null;
49605
49626
  /**
49606
49627
  * @internal
@@ -49661,14 +49682,8 @@ class PlaybackRate extends UICorePlugin {
49661
49682
  onActiveContainerChange() {
49662
49683
  trace(`${T$7} onActiveContainerChange`);
49663
49684
  this.metadataLoaded = false;
49664
- // this.playbackSettingsUpdateReceived = false
49665
49685
  this.listenTo(this.core.activePlayback, Events$1.PLAYBACK_STOP, this.onStop);
49666
49686
  this.listenTo(this.core.activePlayback, Events$1.PLAYBACK_PLAY, this.onPlay);
49667
- // this.listenTo(
49668
- // this.core.activePlayback,
49669
- // Events.PLAYBACK_SETTINGSUPDATE,
49670
- // this.onSettingsUpdate,
49671
- // )
49672
49687
  this.listenTo(this.core.activePlayback, PlaybackEvents.PLAYBACK_RATE_CHANGED, this.onPlaybackRateChange);
49673
49688
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_LOADEDMETADATA, this.onMetaDataLoaded);
49674
49689
  }
@@ -49697,27 +49712,13 @@ class PlaybackRate extends UICorePlugin {
49697
49712
  i18n: this.core.i18n,
49698
49713
  })));
49699
49714
  }
49700
- // private onSettingsUpdate() {
49701
- // trace(`${T} onSettingsUpdate`, {
49702
- // playbackType: this.core.activePlayback.getPlaybackType(),
49703
- // dvrEnabled: this.core.activePlayback.dvrEnabled,
49704
- // })
49705
- // this.playbackSettingsUpdateReceived = true
49706
- // if (this.metadataLoaded) {
49707
- // if (this.mountTimerId) {
49708
- // clearTimeout(this.mountTimerId)
49709
- // this.mountTimerId = null
49710
- // }
49711
- // this.mount()
49712
- // }
49713
- // }
49714
49715
  onMetaDataLoaded() {
49715
49716
  trace(`${T$7} onMetaDataLoaded`, {
49716
49717
  playbackType: this.core.activePlayback.getPlaybackType(),
49717
49718
  dvrEnabled: this.core.activePlayback.dvrEnabled,
49718
49719
  });
49719
- this.metadataLoaded = true;
49720
49720
  this.mountTimerId = setTimeout(() => {
49721
+ this.metadataLoaded = true;
49721
49722
  this.mountTimerId = null;
49722
49723
  this.mount();
49723
49724
  }, 25);
@@ -50140,7 +50141,7 @@ class Poster extends UIContainerPlugin {
50140
50141
  }
50141
50142
  }
50142
50143
 
50143
- const buttonHtml = "<button class='gplayer-lite-btn gcore-skin-text-color gear-option' aria-haspopup=\"menu\">\n <span class=\"gear-option_hd-icon<%= isHd ? '' : ' hidden' %>\"><%= hdIcon %></span>\n <span><%= i18n.t('quality') %></span>\n <span class=\"gear-option_arrow-right-icon\"><%= arrowRightIcon %></span>\n <span class='gear-option_value'><%= currentText %></span>\n</button>\n";
50144
+ const buttonHtml = "<button class='gplayer-lite-btn gcore-skin-text-color gear-option' aria-haspopup=\"menu\">\n <span class=\"gear-option_icon<%= isHd ? '' : ' hidden' %>\"><%= hdIcon %></span>\n <span class=\"gear-option_label\"><%= i18n.t('quality') %></span>\n <span class='gear-option_value'><%= currentText %></span>\n <span class=\"gear-option_arrow-right-icon\"><%= arrowRightIcon %></span>\n</button>\n";
50144
50145
 
50145
50146
  const listHtml = "<button class=\"gplayer-lite-btn go-back gcore-skin-text-color\" id=\"level-selector-back-button\">\n <span class=\"arrow-left-icon\"><%= arrowLeftIcon %></span>\n <%= i18n.t('quality') %>\n</button>\n<ul class=\"gear-sub-menu quality-levels\" id=\"level-selector-menu\" role=\"menu\">\n <% if (!removeAuto) { %>\n <li>\n <a href=\"#\" class='gear-sub-menu_btn gcore-skin-text-color' data-id=\"-1\" id=\"level_selector_auto\">\n <span class=\"check-icon\"><%= checkIcon %></span>\n <%= i18n.t('auto') %>\n </a>\n </li>\n <% } %>\n <% for (const item of levels.slice().reverse()) {\n var disabled = maxLevel >= 0 && item.level > maxLevel\n var checked = item.level === current\n %>\n <li class=\"<%= disabled ? ' disabled' : ''%><%=checked ? ' current' : ''%>\">\n <a href=\"#\"\n class=\"gear-sub-menu_btn gcore-skin-text-color<%= checked ? ' gcore-skin-active' : '' %>\"\n data-id=\"<%= item.level %>\"\n data-disabled=\"<%= disabled %>\"\n data-checked=\"<%= checked %>\"\n role=\"menuitemradio\"\n id=\"level_selector_<%= item.width > item.height ? item.height : item.width %>\"\n >\n <span class=\"check-icon\"><%= checkIcon %></span>\n <%= labels[item.level] %>\n </a>\n </li>\n <% } %>\n</ul>\n";
50146
50147