@gcorevideo/player 2.24.1 → 2.24.3

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 (68) hide show
  1. package/assets/big-mute-button/big-mute-button.ejs +2 -2
  2. package/assets/bottom-gear/gear-sub-menu.scss +1 -0
  3. package/dist/core.js +1 -1
  4. package/dist/index.css +754 -753
  5. package/dist/index.js +151 -130
  6. package/dist/player.d.ts +72 -21
  7. package/docs/api/player.bigmutebutton.md +13 -1
  8. package/docs/api/player.clapprstatssettings.md +51 -4
  9. package/docs/api/player.clapprstatssettings.runeach.md +16 -0
  10. package/docs/api/player.clipspluginsettings.md +1 -1
  11. package/docs/api/player.clipspluginsettings.text.md +1 -1
  12. package/docs/api/player.cmcdconfig.exportids.md +4 -0
  13. package/docs/api/player.cmcdconfig.md +19 -105
  14. package/docs/api/{player.cmcdconfig.version.md → player.cmcdconfigoptions.contentid.md} +5 -3
  15. package/docs/api/player.cmcdconfigoptions.md +79 -0
  16. package/docs/api/{player.cmcdconfigpluginsettings.md → player.cmcdconfigoptions.sessionid.md} +4 -6
  17. package/docs/api/player.extendedevents.md +9 -0
  18. package/docs/api/player.md +37 -31
  19. package/docs/api/player.mediacontrol.getavailableheight.md +24 -0
  20. package/docs/api/player.mediacontrol.md +14 -0
  21. package/docs/api/{player.cmcdconfig.name.md → player.posterpluginsettings.custom.md} +4 -3
  22. package/docs/api/player.posterpluginsettings.md +108 -7
  23. package/docs/api/player.posterpluginsettings.showfornoop.md +16 -0
  24. package/docs/api/player.posterpluginsettings.showonvideoend.md +16 -0
  25. package/docs/api/{player.cmcdconfig.bindevents.md → player.posterpluginsettings.url.md} +4 -7
  26. package/lib/plugins/big-mute-button/BigMuteButton.d.ts +15 -13
  27. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  28. package/lib/plugins/big-mute-button/BigMuteButton.js +68 -83
  29. package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -0
  30. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  31. package/lib/plugins/bottom-gear/BottomGear.js +17 -17
  32. package/lib/plugins/clappr-stats/ClapprStats.d.ts +6 -2
  33. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
  34. package/lib/plugins/clips/Clips.d.ts +1 -1
  35. package/lib/plugins/clips/Clips.d.ts.map +1 -1
  36. package/lib/plugins/clips/Clips.js +2 -1
  37. package/lib/plugins/cmcd-config/CmcdConfig.d.ts +34 -11
  38. package/lib/plugins/cmcd-config/CmcdConfig.d.ts.map +1 -1
  39. package/lib/plugins/cmcd-config/CmcdConfig.js +28 -18
  40. package/lib/plugins/media-control/MediaControl.d.ts +11 -0
  41. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  42. package/lib/plugins/media-control/MediaControl.js +19 -5
  43. package/lib/plugins/poster/Poster.d.ts +7 -3
  44. package/lib/plugins/poster/Poster.d.ts.map +1 -1
  45. package/lib/plugins/source-controller/SourceController.d.ts +1 -0
  46. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  47. package/lib/plugins/source-controller/SourceController.js +20 -9
  48. package/lib/testUtils.d.ts +1 -0
  49. package/lib/testUtils.d.ts.map +1 -1
  50. package/lib/testUtils.js +3 -0
  51. package/package.json +1 -1
  52. package/src/plugins/big-mute-button/BigMuteButton.ts +75 -110
  53. package/src/plugins/big-mute-button/__tests__/BigMuteButton.test.ts +38 -0
  54. package/src/plugins/big-mute-button/__tests__/__snapshots__/BigMuteButton.test.ts.snap +8 -0
  55. package/src/plugins/bottom-gear/BottomGear.ts +40 -28
  56. package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +34 -7
  57. package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +5 -2
  58. package/src/plugins/clappr-stats/ClapprStats.ts +5 -1
  59. package/src/plugins/clips/Clips.ts +3 -2
  60. package/src/plugins/cmcd-config/CmcdConfig.ts +33 -27
  61. package/src/plugins/media-control/MediaControl.ts +23 -6
  62. package/src/plugins/poster/Poster.ts +6 -2
  63. package/src/plugins/source-controller/SourceController.ts +25 -9
  64. package/src/plugins/source-controller/__tests__/SourceController.test.ts +28 -8
  65. package/src/testUtils.ts +3 -0
  66. package/temp/player.api.json +229 -154
  67. package/tsconfig.tsbuildinfo +1 -1
  68. package/docs/api/player.cmcdconfig.supportedversion.md +0 -14
package/dist/index.js CHANGED
@@ -43303,7 +43303,7 @@ class Player {
43303
43303
  }
43304
43304
  }
43305
43305
 
43306
- var version$1 = "2.24.1";
43306
+ var version$1 = "2.24.3";
43307
43307
 
43308
43308
  var packages = {
43309
43309
  "node_modules/@clappr/core": {
@@ -43327,7 +43327,7 @@ function version() {
43327
43327
  };
43328
43328
  }
43329
43329
 
43330
- const pluginHtml$7 = "<button data-audiotracks-button class='gcore-skin-button-color' id=\"audiotracks-button\" aria-haspopup=\"menu\" aria-expanded=\"false\">\n <span class='audio-text'><%= title %></span> <span class=\"audio-arrow\"><%= icon %></span>\n</button>\n<ul class='gcore-skin-bg-color menu hidden' id=\"audiotracks-select\" role=\"menu\">\n <% for (const track of tracks) { %>\n <li>\n <a href=\"#\" class='gcore-skin-text-color' data-audiotracks-select=\"<%= track.id %>\" role=\"menuitemradio\" aria-checked=\"<%= track.id === current %>\">\n <%= track.label %>\n </a>\n </li>\n <% }; %>\n</ul>\n";
43330
+ const pluginHtml$6 = "<button data-audiotracks-button class='gcore-skin-button-color' id=\"audiotracks-button\" aria-haspopup=\"menu\" aria-expanded=\"false\">\n <span class='audio-text'><%= title %></span> <span class=\"audio-arrow\"><%= icon %></span>\n</button>\n<ul class='gcore-skin-bg-color menu hidden' id=\"audiotracks-select\" role=\"menu\">\n <% for (const track of tracks) { %>\n <li>\n <a href=\"#\" class='gcore-skin-text-color' data-audiotracks-select=\"<%= track.id %>\" role=\"menuitemradio\" aria-checked=\"<%= track.id === current %>\">\n <%= track.label %>\n </a>\n </li>\n <% }; %>\n</ul>\n";
43331
43331
 
43332
43332
  const audioArrow = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg width=\"9px\" height=\"6px\" viewBox=\"0 0 9 6\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <!-- Generator: Sketch 49 (51002) - http://www.bohemiancoding.com/sketch -->\n <title>quality-arrow</title>\n <desc>Created with Sketch.</desc>\n <defs></defs>\n <g id=\"quality-arrow\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <path\n d=\"M5.07079194,5.78553848 C4.91457318,5.94277844 4.70551573,6.00941824 4.50028717,5.99893557 C4.2950586,6.00941824 4.08676693,5.94277844 3.92978239,5.78553848 L0.221118462,1.2997069 C-0.0737061539,1.00469478 -0.0737061539,0.526236029 0.221118462,0.231972666 C0.515177299,-0.0630394586 1.23500883,0.00734414472 1.64852907,0.00734414472 L7.77475484,0.00734414472 C8.21201421,0.00734414472 8.48539703,-0.0630394586 8.77945587,0.231972666 C9.07351471,0.526236029 9.07351471,1.00469478 8.77945587,1.2997069 L5.07079194,5.78553848 Z\"\n fill=\"#FFFFFE\"></path>\n </g>\n</svg>\n";
43333
43333
 
@@ -43636,6 +43636,10 @@ const LEFT_ORDER = [
43636
43636
  'duration',
43637
43637
  'dvr',
43638
43638
  ];
43639
+ /**
43640
+ * Extended events for the {@link MediaControl} plugin
43641
+ * @beta
43642
+ */
43639
43643
  var ExtendedEvents;
43640
43644
  (function (ExtendedEvents) {
43641
43645
  ExtendedEvents["MEDIACONTROL_VOLUME"] = "mediacontrol:volume";
@@ -43896,6 +43900,15 @@ class MediaControl extends UICorePlugin {
43896
43900
  this.bindKeyEvents();
43897
43901
  this.show();
43898
43902
  }
43903
+ /**
43904
+ *
43905
+ * @returns Vertical space available to render something on top of the container.
43906
+ * @remarks
43907
+ * This takes into account the container height and excludes the height of the controls bar
43908
+ */
43909
+ getAvailableHeight() {
43910
+ return (this.core.$el.height() - this.$el.find('.media-control-layer').height());
43911
+ }
43899
43912
  /**
43900
43913
  * Set the initial volume, which is preserved when playback is interrupted by an advertisement
43901
43914
  */
@@ -43907,6 +43920,7 @@ class MediaControl extends UICorePlugin {
43907
43920
  onVolumeChanged() {
43908
43921
  this.updateVolumeUI();
43909
43922
  }
43923
+ // TODO check if CONTAINER_SETTINGSUPDATE handler is sufficient
43910
43924
  onLoadedMetadata() {
43911
43925
  const video = this.core.activePlayback?.el;
43912
43926
  // video.webkitSupportsFullscreen is deprecated but iOS appears to only use this
@@ -43995,11 +44009,11 @@ class MediaControl extends UICorePlugin {
43995
44009
  this.applyButtonStyle(this.$playStopToggle);
43996
44010
  }
43997
44011
  mousemoveOnSeekBar(event) {
43998
- const offset = MediaControl.getPageX(event) -
43999
- (this.$seekBarContainer.offset().left ?? 0); // TODO check if the result can be negative
44000
- const hoverOffset = offset -
44001
- (this.$seekBarHover.width() ?? 0) / 2;
44002
- const pos = offset ? Math.min(1, Math.max(offset / this.$seekBarContainer.width(), 0)) : 0;
44012
+ const offset = MediaControl.getPageX(event) - (this.$seekBarContainer.offset().left ?? 0); // TODO check if the result can be negative
44013
+ const hoverOffset = offset - (this.$seekBarHover.width() ?? 0) / 2;
44014
+ const pos = offset
44015
+ ? Math.min(1, Math.max(offset / this.$seekBarContainer.width(), 0))
44016
+ : 0;
44003
44017
  if (this.settings.seekEnabled) {
44004
44018
  // TODO test that it works when the element does not exist
44005
44019
  this.$seekBarHover.css({ left: hoverOffset });
@@ -44793,7 +44807,7 @@ class AudioTracks extends UICorePlugin {
44793
44807
  static get version() {
44794
44808
  return VERSION$7;
44795
44809
  }
44796
- static template = tmpl(pluginHtml$7);
44810
+ static template = tmpl(pluginHtml$6);
44797
44811
  /**
44798
44812
  * @internal
44799
44813
  */
@@ -44934,20 +44948,25 @@ class AudioTracks extends UICorePlugin {
44934
44948
  }
44935
44949
  }
44936
44950
 
44937
- const pluginHtml$6 = "<div class=\"big-mute-icon-wrapper\" data-big-mute>\n <div class=\"big-mute-icon gcore-skin-border-color\" data-big-mute-icon></div>\n</div>\n";
44951
+ const templateHtml$2 = "<div class=\"big-mute-icon-wrapper\" data-big-mute id=\"gplayer-big-mute-button\">\n <div class=\"big-mute-icon gcore-skin-border-color\" data-big-mute-icon id=\"gplayer-big-mute-icon\"></div>\n</div>\n";
44938
44952
 
44939
44953
  const T$h = 'plugins.big_mute_button';
44940
44954
  // TODO rewrite as a container plugin
44941
44955
  /**
44942
- * `PLUGIN` that displays a big mute button over the video when it's muted.
44943
- * Once pressed, it unmutes the video.
44956
+ * `PLUGIN` that displays a big mute button over the video when it's being played muted.
44944
44957
  * @beta
44958
+ * @remarks
44959
+ * When pressed, it unmutes the video.
44960
+ * @example
44961
+ * ```ts
44962
+ * import { BigMuteButton } from '@gcorevideo/player'
44963
+ * Player.registerPlugin(BigMuteButton)
44964
+ * ```
44945
44965
  */
44946
44966
  class BigMuteButton extends UICorePlugin {
44947
- isBigMuteButtonHidden = false;
44967
+ hidden = false;
44968
+ // TODO get back to the ads-related logic later
44948
44969
  _adIsPlaying = false;
44949
- $bigMuteBtnContainer = null;
44950
- $bigMuteButton = null;
44951
44970
  /**
44952
44971
  * @internal
44953
44972
  */
@@ -44960,14 +44979,13 @@ class BigMuteButton extends UICorePlugin {
44960
44979
  get supportedVersion() {
44961
44980
  return { min: CLAPPR_VERSION$1 };
44962
44981
  }
44963
- static template = tmpl(pluginHtml$6);
44982
+ static template = tmpl(templateHtml$2);
44964
44983
  /**
44965
44984
  * @internal
44966
44985
  */
44967
44986
  get events() {
44968
44987
  return {
44969
- 'click .big-mute-icon': 'clicked',
44970
- 'click .big-mute-icon-wrapper': 'destroyBigMuteBtn',
44988
+ 'click': 'clicked',
44971
44989
  };
44972
44990
  }
44973
44991
  /**
@@ -44975,111 +44993,92 @@ class BigMuteButton extends UICorePlugin {
44975
44993
  */
44976
44994
  bindEvents() {
44977
44995
  this.listenTo(this.core, Events$1.CORE_READY, this.onCoreReady);
44996
+ this.listenTo(this.core, Events$1.CORE_ACTIVE_CONTAINER_CHANGED, this.onContainerChanged);
44978
44997
  this.listenTo(this.core, 'core:advertisement:start', this.onStartAd);
44979
44998
  this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd);
44980
- trace(`${T$h} bindEvents`, {
44981
- mediacontrol: !!this.core.mediaControl,
44982
- });
44983
- // TOOD use core.getPlugin('media_control')
44984
- this.listenTo(this.core.mediaControl, Events$1.MEDIACONTROL_RENDERED, this.mediaControlRendered);
44985
44999
  }
44986
45000
  onCoreReady() {
45001
+ }
45002
+ onContainerChanged() {
44987
45003
  this.listenTo(this.core.activeContainer, Events$1.CONTAINER_VOLUME, this.onContainerVolume);
44988
- this.listenTo(this.core.activeContainer, Events$1.CONTAINER_READY, this.onContainerStart);
45004
+ // this.listenTo(
45005
+ // this.core.activeContainer,
45006
+ // Events.CONTAINER_READY,
45007
+ // this.onContainerReady,
45008
+ // )
44989
45009
  this.listenTo(this.core.activePlayback, Events$1.PLAYBACK_ENDED, this.onPlaybackEnded);
45010
+ this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PLAY, this.onPlay);
44990
45011
  }
44991
- onContainerVolume(value) {
44992
- if (value !== 0) {
44993
- this.destroyBigMuteBtn();
45012
+ onPlay(_, { autoPlay }) {
45013
+ const container = this.core.activeContainer;
45014
+ const { volume } = container;
45015
+ const { wasMuted } = this.options;
45016
+ trace(`${T$h} onPlay`, {
45017
+ autoPlay,
45018
+ wasMuted,
45019
+ volume,
45020
+ });
45021
+ if (autoPlay && !wasMuted && volume === 0) {
45022
+ this.mount();
45023
+ }
45024
+ else {
45025
+ this.destroy();
44994
45026
  }
44995
45027
  }
44996
- onContainerStart() {
44997
- if (this.isBigMuteButtonHidden) {
44998
- this.showBigMuteBtn();
45028
+ onContainerVolume(value) {
45029
+ if (value !== 0) {
45030
+ this.destroy();
44999
45031
  }
45000
45032
  }
45001
45033
  onPlaybackEnded() {
45002
- this.hideBigMuteBtn();
45003
- }
45004
- mediaControlRendered() {
45005
- const container = this.core.activeContainer;
45006
- trace(`${T$h} mediaControlRendered`, {
45007
- container: !!container,
45008
- });
45009
- if (container) {
45010
- this.listenTo(container.playback, Events$1.PLAYBACK_PLAY, () => {
45011
- trace(`${T$h} PLAYBACK_PLAY`);
45012
- this.render();
45013
- });
45014
- }
45034
+ this.hide();
45015
45035
  }
45016
45036
  onStartAd() {
45017
45037
  this._adIsPlaying = true;
45018
- if (this.$bigMuteBtnContainer) {
45019
- this.$bigMuteBtnContainer.addClass('hide');
45020
- }
45038
+ this.hide();
45021
45039
  }
45022
45040
  onFinishAd() {
45023
45041
  this._adIsPlaying = false;
45024
- if (this.$bigMuteBtnContainer) {
45025
- this.$bigMuteBtnContainer.removeClass('hide');
45026
- }
45027
- }
45028
- shouldRender() {
45029
- const container = this.core.activeContainer;
45030
- if (!container) {
45031
- return false;
45032
- }
45033
- const { autoPlay, wasMuted } = this.options;
45034
- const volume = container.volume;
45035
- trace(`${T$h} shouldRender`, {
45036
- autoPlay,
45037
- wasMuted,
45038
- volume,
45039
- });
45040
- return autoPlay && !wasMuted && volume === 0;
45042
+ this.show();
45041
45043
  }
45042
45044
  /**
45043
45045
  * @internal
45044
45046
  */
45045
45047
  render() {
45046
- if (this.shouldRender()) {
45047
- trace(`${T$h} render`, {
45048
- el: !!this.$el,
45049
- });
45050
- this.$el.html(BigMuteButton.template());
45051
- this.$bigMuteBtnContainer = this.$el.find('.big-mute-icon-wrapper[data-big-mute]');
45052
- this._adIsPlaying && this.$bigMuteBtnContainer.addClass('hide');
45053
- this.$bigMuteButton = this.$bigMuteBtnContainer.find('.big-mute-icon');
45054
- this.$bigMuteButton.append(volumeMuteIcon);
45055
- const container = this.core.activeContainer;
45056
- container.$el.append(this.$el.get(0));
45057
- }
45048
+ trace(`${T$h} render`);
45049
+ this.$el.html(BigMuteButton.template());
45050
+ this.$el.find('#gplayer-big-mute-icon').append(volumeMuteIcon);
45051
+ // TODO
45052
+ // this._adIsPlaying && this.hide()
45058
45053
  return this;
45059
45054
  }
45060
- hideBigMuteBtn() {
45061
- this.isBigMuteButtonHidden = true;
45062
- this.$bigMuteBtnContainer?.addClass('hide');
45055
+ mount() {
45056
+ this.core.activeContainer.$el.append(this.$el);
45057
+ this.show();
45063
45058
  }
45064
- showBigMuteBtn() {
45065
- this.isBigMuteButtonHidden = false;
45066
- if (this.$bigMuteBtnContainer) {
45067
- this.$bigMuteBtnContainer.removeClass('hide');
45068
- }
45059
+ hide() {
45060
+ this.hidden = true;
45061
+ this.$el.find('#gplayer-big-mute-button')?.addClass('hide');
45069
45062
  }
45070
- destroyBigMuteBtn(e) {
45071
- this.hideBigMuteBtn();
45072
- if (e && e.stopPropagation) {
45073
- e.stopPropagation();
45074
- }
45075
- this.destroy();
45063
+ show() {
45064
+ this.hidden = false;
45065
+ this.$el.find('#gplayer-big-mute-button')?.removeClass('hide');
45076
45066
  }
45077
45067
  clicked(e) {
45068
+ trace(`${T$h} clicked`);
45069
+ const mediaControl = this.core.getPlugin('media_control');
45070
+ // TODO delegate to media_control plugin
45078
45071
  const localVolume = Utils.Config.restore('volume');
45079
45072
  const volume = !isNaN(localVolume) ? localVolume : 100;
45080
- // TODO use container.setVolume() instead
45081
- this.core.mediaControl.setVolume(volume === 0 ? 100 : volume);
45082
- this.destroyBigMuteBtn(e);
45073
+ const unmuted = volume === 0 ? 100 : volume;
45074
+ if (mediaControl) {
45075
+ mediaControl.setVolume(unmuted);
45076
+ }
45077
+ else {
45078
+ this.core.activeContainer.setVolume(unmuted);
45079
+ }
45080
+ e.stopPropagation?.();
45081
+ this.destroy();
45083
45082
  }
45084
45083
  }
45085
45084
 
@@ -45091,6 +45090,8 @@ const gearHdIcon = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\
45091
45090
 
45092
45091
  const VERSION$6 = '2.19.12';
45093
45092
  const T$g = 'plugins.bottom_gear';
45093
+ const MENU_VMARGIN = 12;
45094
+ const MENU_BACKLINK_HEIGHT = 44;
45094
45095
  /**
45095
45096
  * Events triggered by the plugin
45096
45097
  * @beta
@@ -45102,7 +45103,6 @@ var GearEvents;
45102
45103
  */
45103
45104
  GearEvents["RENDERED"] = "rendered";
45104
45105
  })(GearEvents || (GearEvents = {}));
45105
- // TODO disabled if no items added
45106
45106
  /**
45107
45107
  * `PLUGIN` that adds a button to extend the media controls UI with extra options.
45108
45108
  * @beta
@@ -45239,7 +45239,7 @@ class BottomGear extends UICorePlugin {
45239
45239
  * ```
45240
45240
  */
45241
45241
  addItem(name, $subMenu) {
45242
- const $existingItem = this.$el.find(`#gear-options li[data-${name}`);
45242
+ const $existingItem = this.$el.find(`#gear-options li[data-${name}]`);
45243
45243
  if ($existingItem.length) {
45244
45244
  trace(`${T$g} addItem already exists`, { name });
45245
45245
  return $existingItem;
@@ -45254,20 +45254,17 @@ class BottomGear extends UICorePlugin {
45254
45254
  .hide()
45255
45255
  .appendTo(this.$el.find('#gear-options-wrapper'));
45256
45256
  $item.on('click', (e) => {
45257
- trace(`${T$g} addItem submenu clicked`, { name });
45258
45257
  e.stopPropagation();
45258
+ this.alignSubmenu($subMenu);
45259
45259
  $subMenu.show();
45260
45260
  this.$el.find('#gear-options').hide();
45261
45261
  });
45262
45262
  }
45263
45263
  this.numItems++;
45264
- if (this.numItems > 0) {
45265
- this.$el.show();
45266
- }
45264
+ this.$el.show();
45267
45265
  return $item;
45268
45266
  }
45269
45267
  bindContainerEvents(container) {
45270
- trace(`${T$g} bindContainerEvents`);
45271
45268
  this.listenTo(container, Events$1.CONTAINER_HIGHDEFINITIONUPDATE, this.highDefinitionUpdate);
45272
45269
  this.listenTo(container, Events$1.CONTAINER_CLICK, () => {
45273
45270
  this.collapse();
@@ -45282,7 +45279,6 @@ class BottomGear extends UICorePlugin {
45282
45279
  * @internal
45283
45280
  */
45284
45281
  render() {
45285
- trace(`${T$g} render`);
45286
45282
  const mediaControl = this.core.getPlugin('media_control');
45287
45283
  if (!mediaControl) {
45288
45284
  return this; // TODO test
@@ -45323,11 +45319,11 @@ class BottomGear extends UICorePlugin {
45323
45319
  else {
45324
45320
  this.$el.find('#gear-options-wrapper').show();
45325
45321
  }
45326
- this.$el.find('#gear-button').attr('aria-expanded', (!this.collapsed).toString());
45327
- trace(`${T$g} toggleMenu`, { hidden: this.collapsed });
45322
+ this.$el
45323
+ .find('#gear-button')
45324
+ .attr('aria-expanded', (!this.collapsed).toString());
45328
45325
  }
45329
45326
  collapse() {
45330
- trace(`${T$g} collapse`);
45331
45327
  this.collapsed = true;
45332
45328
  this.$el.find('#gear-options-wrapper').hide();
45333
45329
  this.$el.find('#gear-button').attr('aria-expanded', 'false');
@@ -45335,7 +45331,6 @@ class BottomGear extends UICorePlugin {
45335
45331
  this.collapseSubmenus();
45336
45332
  }
45337
45333
  onCoreReady() {
45338
- trace(`${T$g} onCoreReady`);
45339
45334
  const mediaControl = this.core.getPlugin('media_control');
45340
45335
  assert(mediaControl, 'media_control plugin is required');
45341
45336
  this.listenTo(mediaControl, Events$1.MEDIACONTROL_RENDERED, this.onMediaControlRendered);
@@ -45351,16 +45346,20 @@ class BottomGear extends UICorePlugin {
45351
45346
  this.bindContainerEvents(mediaControl.container);
45352
45347
  }
45353
45348
  onMediaControlRendered() {
45354
- trace(`${T$g} onMediaControlRendered`);
45355
45349
  this.mount();
45356
45350
  }
45357
45351
  mount() {
45358
- trace(`${T$g} mount`, {
45359
- numItems: this.numItems,
45360
- });
45361
45352
  const mediaControl = this.core.getPlugin('media_control');
45362
45353
  mediaControl.mount('gear', this.$el);
45363
45354
  }
45355
+ alignSubmenu($subMenu) {
45356
+ const availableHeight = this.core.getPlugin('media_control').getAvailableHeight() -
45357
+ MENU_VMARGIN * 2;
45358
+ $subMenu.css('max-height', `${availableHeight}px`);
45359
+ $subMenu
45360
+ .find('.gear-sub-menu')
45361
+ .css('max-height', `${availableHeight - MENU_BACKLINK_HEIGHT}px`);
45362
+ }
45364
45363
  }
45365
45364
 
45366
45365
  /**
@@ -45726,24 +45725,42 @@ const CMCD_KEYS = [
45726
45725
  ];
45727
45726
  // const T = 'plugins.cmcd'
45728
45727
  /**
45729
- * A `PLUGIN` that configures CMCD for playback
45728
+ * A `PLUGIN` that configures {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf | CMCD} for playback
45730
45729
  * @beta
45731
45730
  * @remarks
45732
- * Configuration options
45733
- * `cmcd`: {@link CmcdConfigPluginSettings}
45731
+ * Configuration options - {@link CmcdConfigOptions}.
45732
+ * @example
45733
+ * ```ts
45734
+ * import { CmcdConfig } from '@gcorevideo/player'
45735
+ * Player.registerPlugin(CmcdConfig)
45736
+ *
45737
+ * const player = new Player({
45738
+ * source: 'https://example.com/video.mp4',
45739
+ * cmcd: {
45740
+ * sessionId: '1234567890',
45741
+ * contentId: 'f572d396fae9206628714fb2ce00f72e94f2258f',
45742
+ * },
45743
+ * })
45744
+ * ```
45734
45745
  */
45735
45746
  class CmcdConfig extends CorePlugin {
45736
45747
  sid;
45737
45748
  cid = '';
45738
45749
  /**
45739
- * @inheritdocs
45750
+ * @internal
45740
45751
  */
45741
45752
  get name() {
45742
45753
  return 'cmcd';
45743
45754
  }
45755
+ /**
45756
+ * @internal
45757
+ */
45744
45758
  get version() {
45745
45759
  return '0.1.0';
45746
45760
  }
45761
+ /**
45762
+ * @internal
45763
+ */
45747
45764
  get supportedVersion() {
45748
45765
  return CLAPPR_VERSION$1;
45749
45766
  }
@@ -45753,11 +45770,16 @@ class CmcdConfig extends CorePlugin {
45753
45770
  this.cid = this.options.cmcd?.contentId ?? this.generateContentId();
45754
45771
  }
45755
45772
  /**
45756
- * @inheritdocs
45773
+ * @internal
45757
45774
  */
45758
45775
  bindEvents() {
45759
45776
  this.listenTo(this.core, Events$1.CORE_CONTAINERS_CREATED, () => this.updateSettings(this.core.containers[0]));
45760
45777
  }
45778
+ /**
45779
+ * Returns the current `sid` and `cid` values.
45780
+ * Useful when the auto-generated values need to be known.
45781
+ * @returns `sid` and `cid` values
45782
+ */
45761
45783
  exportIds() {
45762
45784
  return {
45763
45785
  sid: this.sid,
@@ -45793,19 +45815,6 @@ class CmcdConfig extends CorePlugin {
45793
45815
  break;
45794
45816
  }
45795
45817
  }
45796
- updateHlsjsSettings(options, { cid, sid }) {
45797
- $.extend(true, options, {
45798
- playback: {
45799
- hlsjsConfig: {
45800
- cmcd: {
45801
- includeKeys: CMCD_KEYS,
45802
- sessionId: sid,
45803
- contentId: cid,
45804
- },
45805
- },
45806
- },
45807
- });
45808
- }
45809
45818
  generateContentId() {
45810
45819
  return new URL(this.core.options.source ?? this.core.options.sources[0].source).pathname.slice(0, 64);
45811
45820
  }
@@ -48517,7 +48526,8 @@ class Clips extends UICorePlugin {
48517
48526
  * @returns The text of the clip at the given time
48518
48527
  */
48519
48528
  getText(time) {
48520
- return this.clips.find((clip) => clip.start <= time && clip.end >= time)?.text;
48529
+ return this.clips.find((clip) => clip.start <= time && clip.end >= time)
48530
+ ?.text;
48521
48531
  }
48522
48532
  onCoreReady() {
48523
48533
  trace(`${T$d} onCoreReady`);
@@ -51313,6 +51323,7 @@ class SourceController extends CorePlugin {
51313
51323
  currentSourceIndex = 0;
51314
51324
  sourcesDelay = {};
51315
51325
  active = false;
51326
+ autoPlay = false;
51316
51327
  switching = false;
51317
51328
  sync = noSync;
51318
51329
  /**
@@ -51388,6 +51399,7 @@ class SourceController extends CorePlugin {
51388
51399
  if (this.switching) {
51389
51400
  return;
51390
51401
  }
51402
+ this.autoPlay = !!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay;
51391
51403
  switch (error.code) {
51392
51404
  case PlaybackErrorCode.MediaSourceUnavailable:
51393
51405
  this.core.activeContainer?.getPlugin('poster')?.disable();
@@ -51406,6 +51418,12 @@ class SourceController extends CorePlugin {
51406
51418
  this.core.activeContainer?.getPlugin('spinner')?.hide();
51407
51419
  }
51408
51420
  });
51421
+ this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PLAY, (_, { autoPlay }) => {
51422
+ trace(`${T$4} onContainerPlay`, {
51423
+ autoPlay,
51424
+ });
51425
+ this.autoPlay = !!autoPlay;
51426
+ });
51409
51427
  }
51410
51428
  reset() {
51411
51429
  this.active = false;
@@ -51423,17 +51441,20 @@ class SourceController extends CorePlugin {
51423
51441
  trace(`${T$4} retryPlayback syncing...`, {
51424
51442
  nextSource,
51425
51443
  });
51426
- const rnd = RETRY_DELAY_BLUR * Math.random();
51444
+ const rnd = Math.round(RETRY_DELAY_BLUR * Math.random());
51427
51445
  this.sync(() => {
51428
- trace(`${T$4} retryPlayback loading...`);
51429
51446
  this.switching = false;
51430
51447
  this.core.load(nextSource.source, nextSource.mimeType);
51431
51448
  trace(`${T$4} retryPlayback loaded`, {
51432
51449
  nextSource,
51433
51450
  });
51434
51451
  setTimeout(() => {
51435
- this.core.activePlayback.play();
51436
- trace(`${T$4} retryPlayback playing`);
51452
+ trace(`${T$4} retryPlayback playing`, {
51453
+ autoPlay: this.autoPlay,
51454
+ });
51455
+ this.core.activeContainer.play({
51456
+ autoPlay: this.autoPlay,
51457
+ });
51437
51458
  }, rnd);
51438
51459
  });
51439
51460
  });