@gcorevideo/player 2.20.7 → 2.20.9

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 (218) hide show
  1. package/dist/core.js +54 -25
  2. package/dist/index.css +1184 -1184
  3. package/dist/index.js +298 -267
  4. package/dist/player.d.ts +178 -126
  5. package/dist/plugins/index.css +841 -841
  6. package/dist/plugins/index.js +192 -192
  7. package/docs/api/player.bottomgear.md +14 -0
  8. package/docs/api/player.bottomgear.refresh.md +20 -0
  9. package/docs/api/player.clapprnerdstats.md +1 -1
  10. package/docs/api/player.clapprstats.exportmetrics.md +1 -1
  11. package/docs/api/player.clapprstats.md +1 -15
  12. package/docs/api/player.clapprstats.setupdatemetrics.md +2 -0
  13. package/docs/api/player.clipsplugin.md +1 -1
  14. package/docs/api/player.clipspluginsettings.md +5 -2
  15. package/docs/api/player.clipspluginsettings.text.md +3 -0
  16. package/docs/api/{player.errorscreen.bindevents.md → player.containerpluginconstructor.md} +7 -6
  17. package/docs/api/{player.errorscreen.render.md → player.corepluginconstructor.md} +7 -6
  18. package/docs/api/player.errordesc.md +28 -0
  19. package/docs/api/player.errorscreen.md +1 -220
  20. package/docs/api/{player.errorscreen.hide.md → player.errorscreenpluginsettings.md} +7 -7
  21. package/docs/api/player.levelselector.md +3 -9
  22. package/docs/api/player.levelselectorpluginsettings.labels.md +24 -0
  23. package/docs/api/player.levelselectorpluginsettings.md +79 -0
  24. package/docs/api/player.levelselectorpluginsettings.restrictresolution.md +16 -0
  25. package/docs/api/player.md +93 -16
  26. package/docs/api/{player.errorscreen.container.md → player.mediacontrol.currentseekpos.md} +3 -3
  27. package/docs/api/player.mediacontrol.disable.md +1 -1
  28. package/docs/api/player.mediacontrol.md +23 -2
  29. package/docs/api/{player.gearevents.md → player.mediacontrolevents.md} +4 -4
  30. package/docs/api/player.multicamera.md +1 -29
  31. package/docs/api/player.playbackerror.md +19 -0
  32. package/docs/api/{player.errorscreen.supportedversion.md → player.playbackerror.ui.md} +7 -4
  33. package/docs/api/player.playbackerrorcode.md +3 -3
  34. package/docs/api/{player.errorscreen.show.md → player.playbackrate._constructor_.md} +7 -11
  35. package/docs/api/player.playbackrate.md +35 -2
  36. package/docs/api/player.player.registerplugin.md +2 -2
  37. package/docs/api/player.player.unregisterplugin.md +2 -2
  38. package/docs/api/player.playerpluginconstructor.md +17 -0
  39. package/docs/api/player.share.attributes.md +3 -0
  40. package/docs/api/player.share.bindevents.md +3 -0
  41. package/docs/api/player.share.canshowshare.md +3 -0
  42. package/docs/api/player.share.events.md +3 -0
  43. package/docs/api/player.share.hideshare.md +3 -0
  44. package/docs/api/player.share.initializeicons.md +3 -0
  45. package/docs/api/player.share.md +40 -1
  46. package/docs/api/player.share.name.md +3 -0
  47. package/docs/api/player.share.onshareembedclick.md +3 -0
  48. package/docs/api/player.share.onsharefb.md +3 -0
  49. package/docs/api/player.share.onsharehide.md +3 -0
  50. package/docs/api/player.share.onsharelinkclick.md +3 -0
  51. package/docs/api/player.share.onshareshow.md +3 -0
  52. package/docs/api/player.share.onsharetw.md +3 -0
  53. package/docs/api/player.share.render.md +3 -0
  54. package/docs/api/player.share.showshare.md +3 -0
  55. package/docs/api/player.share.supportedversion.md +3 -0
  56. package/docs/api/player.share.template.md +3 -0
  57. package/docs/api/player.share.unbindevents.md +3 -0
  58. package/docs/api/player.skiptime.attributes.md +3 -0
  59. package/docs/api/player.skiptime.bindevents.md +3 -0
  60. package/docs/api/player.skiptime.container.md +3 -0
  61. package/docs/api/player.skiptime.events.md +3 -0
  62. package/docs/api/player.skiptime.handlerewindclicks.md +3 -0
  63. package/docs/api/player.skiptime.md +30 -1
  64. package/docs/api/player.skiptime.name.md +3 -0
  65. package/docs/api/player.skiptime.render.md +3 -0
  66. package/docs/api/player.skiptime.setback.md +3 -0
  67. package/docs/api/player.skiptime.setforward.md +3 -0
  68. package/docs/api/player.skiptime.setmidclick.md +3 -0
  69. package/docs/api/player.skiptime.supportedversion.md +3 -0
  70. package/docs/api/player.skiptime.template.md +3 -0
  71. package/docs/api/player.skiptime.togglefullscreen.md +3 -0
  72. package/docs/api/player.spinnerevents.md +4 -1
  73. package/docs/api/player.spinnerthreebounce.hide.md +1 -1
  74. package/docs/api/player.spinnerthreebounce.md +7 -5
  75. package/docs/api/player.spinnerthreebounce.show.md +40 -2
  76. package/docs/api/player.telemetry.md +1 -1
  77. package/docs/api/player.telemetrypluginsettings.md +1 -1
  78. package/docs/api/{player.errorscreen.unbindevents.md → player.telemetrysendfn.md} +6 -6
  79. package/lib/Player.d.ts +13 -4
  80. package/lib/Player.d.ts.map +1 -1
  81. package/lib/Player.js +17 -12
  82. package/lib/index.core.d.ts +0 -1
  83. package/lib/index.core.d.ts.map +1 -1
  84. package/lib/index.core.js +0 -1
  85. package/lib/index.plugins.d.ts +0 -1
  86. package/lib/index.plugins.d.ts.map +1 -1
  87. package/lib/index.plugins.js +0 -1
  88. package/lib/playback/BasePlayback.d.ts +5 -0
  89. package/lib/playback/BasePlayback.d.ts.map +1 -1
  90. package/lib/playback/BasePlayback.js +8 -0
  91. package/lib/playback/HTML5Video.d.ts +4 -0
  92. package/lib/playback/HTML5Video.d.ts.map +1 -0
  93. package/lib/playback/HTML5Video.js +3 -0
  94. package/lib/playback/dash-playback/DashPlayback.d.ts +1 -0
  95. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  96. package/lib/playback/dash-playback/DashPlayback.js +6 -2
  97. package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
  98. package/lib/playback/hls-playback/HlsPlayback.js +1 -1
  99. package/lib/playback/index.d.ts.map +1 -1
  100. package/lib/playback/index.js +2 -0
  101. package/lib/playback/types.d.ts +9 -0
  102. package/lib/playback/types.d.ts.map +1 -0
  103. package/lib/playback/types.js +9 -0
  104. package/lib/plugins/bottom-gear/BottomGear.d.ts +7 -12
  105. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  106. package/lib/plugins/bottom-gear/BottomGear.js +5 -14
  107. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +1 -1
  108. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +3 -3
  109. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -1
  110. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +8 -8
  111. package/lib/plugins/clappr-stats/ClapprStats.d.ts +4 -5
  112. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
  113. package/lib/plugins/clappr-stats/ClapprStats.js +4 -3
  114. package/lib/plugins/clips/Clips.d.ts +3 -2
  115. package/lib/plugins/clips/Clips.d.ts.map +1 -1
  116. package/lib/plugins/clips/Clips.js +1 -1
  117. package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -1
  118. package/lib/plugins/dvr-controls/DvrControls.d.ts +4 -3
  119. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
  120. package/lib/plugins/dvr-controls/DvrControls.js +30 -18
  121. package/lib/plugins/error-screen/ErrorScreen.d.ts +12 -1
  122. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
  123. package/lib/plugins/error-screen/ErrorScreen.js +1 -1
  124. package/lib/plugins/index.d.ts +0 -1
  125. package/lib/plugins/index.d.ts.map +1 -1
  126. package/lib/plugins/index.js +0 -1
  127. package/lib/plugins/kibo/index.d.ts +0 -3
  128. package/lib/plugins/kibo/index.d.ts.map +1 -1
  129. package/lib/plugins/kibo/index.js +0 -3
  130. package/lib/plugins/level-selector/LevelSelector.d.ts +8 -4
  131. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  132. package/lib/plugins/level-selector/LevelSelector.js +16 -7
  133. package/lib/plugins/media-control/MediaControl.d.ts +5 -4
  134. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  135. package/lib/plugins/media-control/MediaControl.js +8 -6
  136. package/lib/plugins/multi-camera/MultiCamera.d.ts +3 -11
  137. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
  138. package/lib/plugins/multi-camera/MultiCamera.js +1 -1
  139. package/lib/plugins/playback-rate/PlaybackRate.d.ts +11 -10
  140. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  141. package/lib/plugins/playback-rate/PlaybackRate.js +83 -91
  142. package/lib/plugins/poster/Poster.js +2 -2
  143. package/lib/plugins/share/Share.d.ts +2 -1
  144. package/lib/plugins/share/Share.d.ts.map +1 -1
  145. package/lib/plugins/share/Share.js +2 -1
  146. package/lib/plugins/skip-time/SkipTime.d.ts +2 -1
  147. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
  148. package/lib/plugins/skip-time/SkipTime.js +2 -1
  149. package/lib/plugins/source-controller/SourceController.js +3 -3
  150. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +6 -3
  151. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  152. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +6 -3
  153. package/lib/plugins/telemetry/Telemetry.d.ts +2 -3
  154. package/lib/plugins/telemetry/Telemetry.d.ts.map +1 -1
  155. package/lib/plugins/telemetry/Telemetry.js +1 -1
  156. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -1
  157. package/lib/plugins/vast-ads/VastAds.js +3 -3
  158. package/lib/plugins/vast-ads/roll.d.ts +1 -1
  159. package/lib/plugins/vast-ads/roll.d.ts.map +1 -1
  160. package/lib/plugins/vast-ads/rollmanager.d.ts +1 -1
  161. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -1
  162. package/lib/plugins/vast-ads/rollmanager.js +2 -2
  163. package/lib/types.d.ts +21 -5
  164. package/lib/types.d.ts.map +1 -1
  165. package/lib/utils/types.d.ts +0 -6
  166. package/lib/utils/types.d.ts.map +1 -1
  167. package/package.json +1 -1
  168. package/src/Player.ts +18 -16
  169. package/src/index.core.ts +0 -1
  170. package/src/index.plugins.ts +0 -1
  171. package/src/playback/BasePlayback.ts +12 -4
  172. package/src/playback/HTML5Video.ts +3 -0
  173. package/src/playback/dash-playback/DashPlayback.ts +15 -11
  174. package/src/playback/hls-playback/HlsPlayback.ts +7 -11
  175. package/src/playback/index.ts +2 -1
  176. package/src/playback/types.ts +9 -0
  177. package/src/plugins/audio-selector/AudioSelector.ts +1 -1
  178. package/src/plugins/big-mute-button/BigMuteButton.ts +1 -1
  179. package/src/plugins/bottom-gear/BottomGear.ts +7 -16
  180. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +5 -5
  181. package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +184 -187
  182. package/src/plugins/clappr-stats/ClapprStats.ts +5 -4
  183. package/src/plugins/clips/Clips.ts +4 -3
  184. package/src/plugins/context-menu/ContextMenu.ts +0 -2
  185. package/src/plugins/dvr-controls/DvrControls.ts +90 -56
  186. package/src/plugins/error-screen/ErrorScreen.ts +12 -1
  187. package/src/plugins/favicon/Favicon.ts +1 -1
  188. package/src/plugins/index.ts +0 -1
  189. package/src/plugins/kibo/index.ts +0 -3
  190. package/src/plugins/level-selector/LevelSelector.ts +24 -10
  191. package/src/plugins/logo/Logo.ts +1 -1
  192. package/src/plugins/media-control/MediaControl.ts +13 -10
  193. package/src/plugins/multi-camera/MultiCamera.ts +4 -4
  194. package/src/plugins/playback-rate/PlaybackRate.ts +90 -106
  195. package/src/plugins/poster/Poster.ts +3 -3
  196. package/src/plugins/seek-time/SeekTime.ts +1 -1
  197. package/src/plugins/share/Share.ts +2 -1
  198. package/src/plugins/skip-time/SkipTime.ts +2 -1
  199. package/src/plugins/source-controller/SourceController.ts +3 -3
  200. package/src/plugins/source-controller/__tests__/SourceController.test.ts +2 -2
  201. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +6 -3
  202. package/src/plugins/subtitles/Subtitles.ts +1 -1
  203. package/src/plugins/telemetry/Telemetry.ts +2 -2
  204. package/src/plugins/thumbnails/Thumbnails.ts +1 -1
  205. package/src/plugins/vast-ads/VastAds.ts +5 -4
  206. package/src/plugins/vast-ads/roll.ts +2 -1
  207. package/src/plugins/vast-ads/rollmanager.ts +3 -3
  208. package/src/types.ts +24 -5
  209. package/src/utils/types.ts +0 -8
  210. package/temp/player.api.json +540 -576
  211. package/tsconfig.tsbuildinfo +1 -1
  212. package/assets/playback-rate/playback-rate-selector.ejs +0 -9
  213. package/docs/api/player.clapprstats.onbitrate.md +0 -52
  214. package/docs/api/player.errorscreen.attributes.md +0 -17
  215. package/docs/api/player.errorscreen.name.md +0 -14
  216. package/docs/api/player.errorscreen.template.md +0 -14
  217. package/docs/api/player.multicamera.getcameraslist.md +0 -18
  218. package/docs/api/player.multicamera.getcurrentcamera.md +0 -18
@@ -1,15 +1,19 @@
1
- import { Events, UICorePlugin, Playback, template } from '@clappr/core';
1
+ import { Events, UICorePlugin, Playback, template, Core } from '@clappr/core';
2
+ import { trace } from '@gcorevideo/utils';
3
+ import assert from 'assert';
2
4
 
3
5
  import { CLAPPR_VERSION } from '../../build.js';
4
- import type { ZeptoResult } from '../../utils/types.js';
6
+ import type { ZeptoResult } from '../../types.js';
5
7
 
6
- import pluginHtml from '../../../assets/playback-rate/playback-rate-selector.ejs';
7
8
  import buttonHtml from '../../../assets/playback-rate/button.ejs';
8
9
  import listHtml from '../../../assets/playback-rate/list.ejs';
9
10
  import speedIcon from '../../../assets/icons/new/speed.svg';
10
11
  import arrowRightIcon from '../../../assets/icons/new/arrow-right.svg';
11
12
  import arrowLeftIcon from '../../../assets/icons/new/arrow-left.svg';
12
13
  import checkIcon from '../../../assets/icons/new/check.svg';
14
+ import { BottomGear } from '../bottom-gear/BottomGear.js';
15
+ import { PlaybackEvents } from '../../playback/types.js';
16
+ import { MediaControl, MediaControlEvents } from '../media-control/MediaControl.js';
13
17
 
14
18
  type PlaybackRateOption = {
15
19
  value: string;
@@ -28,11 +32,10 @@ const DEFAULT_PLAYBACK_RATES = [
28
32
 
29
33
  const DEFAULT_PLAYBACK_RATE = '1.0';
30
34
 
31
- // TODO
32
- const MEDIACONTROL_PLAYBACKRATE = 'playbackRate';
35
+ const T = 'plugins.playback_rate';
33
36
 
34
37
  /**
35
- * Allows changing the playback speed of the video.
38
+ * PLUGIN that allows changing the playback speed of the video.
36
39
  * @beta
37
40
  *
38
41
  * @remarks
@@ -42,15 +45,16 @@ const MEDIACONTROL_PLAYBACKRATE = 'playbackRate';
42
45
  *
43
46
  * - {@link BottomGear | bottom_gear}
44
47
  *
45
- * It renders a button in the gear menu, which opens a dropdown with the available playback rates.
48
+ * It renders a button in the gear menu, which opens a dropdown with the options to change the playback rate.
46
49
  */
47
50
  export class PlaybackRate extends UICorePlugin {
48
- private currentPlayback: Playback | null = null;
49
-
50
51
  private playbackRates: PlaybackRateOption[] = DEFAULT_PLAYBACK_RATES;
51
52
 
53
+ // Saved when an ad starts to restore after it finishes
52
54
  private prevSelectedRate: string | undefined;
53
55
 
56
+ private rendered = false;
57
+
54
58
  private selectedRate: string = DEFAULT_PLAYBACK_RATE;
55
59
 
56
60
  /**
@@ -67,12 +71,16 @@ export class PlaybackRate extends UICorePlugin {
67
71
  return { min: CLAPPR_VERSION };
68
72
  }
69
73
 
70
- private static readonly template = template(pluginHtml);
71
-
72
74
  private static readonly buttonTemplate = template(buttonHtml);
73
75
 
74
76
  private static readonly listTemplate = template(listHtml);
75
77
 
78
+ constructor(core: Core) {
79
+ super(core);
80
+ this.playbackRates = core.options.playbackRate?.options || DEFAULT_PLAYBACK_RATES;
81
+ this.selectedRate = core.options.playbackRate?.defaultValue || DEFAULT_PLAYBACK_RATE;
82
+ }
83
+
76
84
  /**
77
85
  * @internal
78
86
  */
@@ -98,31 +106,40 @@ export class PlaybackRate extends UICorePlugin {
98
106
  * @internal
99
107
  */
100
108
  override bindEvents() {
101
- this.listenTo(this.core, 'gear:rendered', this.render);
102
- // TODO this.core.getPlugin('media_control'), bottom_gear
103
- this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
104
- this.listenTo(this.core.mediaControl, MEDIACONTROL_PLAYBACKRATE, this.updatePlaybackRate);
105
-
106
- this.listenTo(this.core, 'core:advertisement:start', this.onStartAd);
107
- this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd);
108
- if (this.core.activeContainer) {
109
- this.listenTo(this.core.activePlayback, Events.PLAYBACK_BUFFERFULL, this.updateLiveStatus);
110
- }
109
+ this.listenTo(this.core, Events.CORE_READY, this.onCoreReady);
110
+ this.listenTo(this.core, Events.CORE_ACTIVE_CONTAINER_CHANGED, this.onActiveContainerChange);
111
+ }
111
112
 
112
- if (this.currentPlayback) {
113
- this.listenTo(this.currentPlayback, Events.PLAYBACK_STOP, this.onStop);
114
- this.listenTo(this.currentPlayback, Events.PLAYBACK_PLAY, this.onPlay);
113
+ private onCoreReady() {
114
+ const mediaControl = this.core.getPlugin('media_control');
115
+ assert(mediaControl, 'media_control plugin is required');
116
+ const gear = this.core.getPlugin('bottom_gear') as BottomGear;
117
+ assert(gear, 'bottom_gear plugin is required');
118
+ this.listenTo(mediaControl, MediaControlEvents.MEDIACONTROL_GEAR_RENDERED, this.onGearRendered);
119
+ }
115
120
 
116
- // TODO import dash playback events
117
- this.listenTo(this.currentPlayback, 'dash:playback-rate-changed', this.onDashRateChange);
118
- }
121
+ private onActiveContainerChange() {
122
+ this.listenTo(this.core.activePlayback, Events.PLAYBACK_STOP, this.onStop);
123
+ this.listenTo(this.core.activePlayback, Events.PLAYBACK_PLAY, this.onPlay);
124
+ this.listenTo(this.core.activePlayback, PlaybackEvents.PLAYBACK_RATE_CHANGED, this.onPlaybackRateChange);
125
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAYBACKDVRSTATECHANGED, this.onDvrStateChanged);
119
126
  }
120
127
 
121
- private unBindEvents() {
122
- this.stopListening(this.core, 'gear:rendered', this.render);
123
- this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
124
- this.stopListening(this.core, 'core:advertisement:start', this.onStartAd);
125
- this.stopListening(this.core, 'core:advertisement:finish', this.onFinishAd);
128
+ private onGearRendered() {
129
+ trace(`${T} onGearRendered`, {
130
+ rendered: this.rendered,
131
+ });
132
+ this.rendered = false;
133
+ this.render();
134
+ }
135
+
136
+ private onDvrStateChanged(dvrEnabled: boolean) {
137
+ trace(`${T} onDvrStateChanged`, {
138
+ dvrEnabled,
139
+ })
140
+ if (dvrEnabled) {
141
+ this.render();
142
+ }
126
143
  }
127
144
 
128
145
  private allRateElements(): ZeptoResult {
@@ -133,86 +150,65 @@ export class PlaybackRate extends UICorePlugin {
133
150
  return (this.$(`ul.gear-sub-menu a[data-rate="${rate}"]`) as ZeptoResult).parent();
134
151
  }
135
152
 
136
- private onDashRateChange() {
137
- // TODO consider removing
138
- ((this.currentPlayback as any)._dash as any)?.setPlaybackRate(this.selectedRate);
139
- }
140
-
141
- private updateLiveStatus() {
142
- if (this.core.getPlaybackType() === Playback.LIVE) {
143
- if (this.core.mediaControl.currentSeekBarPercentage <= 98.9) {
144
- this.core.mediaControl.$playbackRate.removeClass('playbackrate-enable');
145
- this.core.mediaControl.$el.addClass('dvr');
146
-
147
- return;
148
- }
149
- this.updatePlaybackRate(DEFAULT_PLAYBACK_RATE);
150
- this.core.mediaControl.$playbackRate.addClass('playbackrate-enable');
151
- this.core.mediaControl.$el.removeClass('dvr');
153
+ private onPlaybackRateChange(playbackRate: number) {
154
+ const selectedRate = parseInt(this.selectedRate, 10);
155
+ if (playbackRate !== selectedRate) {
156
+ trace(`${T} onPlaybackRateChange setting target rate`, {
157
+ playbackRate,
158
+ selectedRate,
159
+ })
160
+ this.core.activePlayback?.setPlaybackRate(selectedRate);
152
161
  }
153
162
  }
154
163
 
155
- private reload() {
156
- this.unBindEvents();
157
- this.bindEvents();
158
- }
159
-
160
164
  private shouldRender() {
161
165
  if (!this.core.activeContainer) {
162
166
  return false;
163
167
  }
164
168
 
165
- this.currentPlayback = this.core.activePlayback;
169
+ if (this.core.getPlaybackType() === Playback.LIVE && !this.core.activePlayback.dvrEnabled) {
170
+ return false;
171
+ }
166
172
 
167
- return !(this.currentPlayback?.tagName !== 'video' && this.currentPlayback?.tagName !== 'audio');
173
+ return 'setPlaybackRate' in this.core.activePlayback;
168
174
  }
169
175
 
170
176
  /**
171
177
  * @internal
172
178
  */
173
179
  override render() {
174
- const container = this.core.activeContainer;
180
+ trace(`${T} render`, {
181
+ rendered: this.rendered,
182
+ shouldRender: this.shouldRender(),
183
+ })
175
184
 
176
- if (this.core.getPlaybackType() === Playback.LIVE && !container.isDvrEnabled()) {
185
+ if (!this.shouldRender()) {
177
186
  return this;
178
187
  }
179
- const cfg = this.core.options.playbackRateConfig || {};
180
188
 
181
- if (!this.playbackRates) {
182
- this.playbackRates = cfg.options || DEFAULT_PLAYBACK_RATES;
183
- }
184
-
185
- if (!this.selectedRate) {
186
- this.selectedRate = cfg.defaultValue || DEFAULT_PLAYBACK_RATE;
189
+ if (this.rendered) {
190
+ return this;
187
191
  }
188
192
 
189
- if (this.shouldRender()) {
190
- const button = PlaybackRate.buttonTemplate({
191
- title: this.getTitle(),
192
- speedIcon,
193
- arrowRightIcon,
194
- });
195
-
196
- this.$el.html(button);
197
-
198
- // if (this.core.getPlaybackType() === Playback.LIVE) {
199
- // this.core.mediaControl.$playbackRate.addClass('playbackrate-enable');
200
- // }
193
+ const button = PlaybackRate.buttonTemplate({
194
+ title: this.getTitle(),
195
+ speedIcon,
196
+ arrowRightIcon,
197
+ });
201
198
 
202
- // this.core.mediaControl.$playbackRate.append(this.el);
199
+ this.$el.html(button);
203
200
 
204
- this.core.mediaControl.$el?.find('.gear-options-list [data-rate]').html(this.el);
201
+ (this.core.getPlugin('bottom_gear') as BottomGear)?.getElement('rate')?.html(this.el);
205
202
 
206
- // this.updateText();
207
- }
203
+ this.rendered = true;
208
204
 
209
205
  return this;
210
206
  }
211
207
 
212
208
  private onStartAd() {
213
209
  this.prevSelectedRate = this.selectedRate;
214
- this.setSelectedRate('1.0');
215
- this.listenToOnce(this.currentPlayback, Events.PLAYBACK_PLAY, this.onFinishAd);
210
+ this.resetPlaybackRate();
211
+ this.listenToOnce(this.core.activePlayback, Events.PLAYBACK_PLAY, this.onFinishAd);
216
212
  }
217
213
 
218
214
  private onFinishAd() {
@@ -222,16 +218,17 @@ export class PlaybackRate extends UICorePlugin {
222
218
  }
223
219
 
224
220
  private onPlay() {
225
- if (!this.core.mediaControl.$el.hasClass('dvr')) {
226
- if (this.core.getPlaybackType() === Playback.LIVE) {
227
- this.updatePlaybackRate(DEFAULT_PLAYBACK_RATE);
228
- this.core.mediaControl.$playbackRate.addClass('playbackrate-enable');
229
- }
221
+ if (this.core.getPlaybackType() === Playback.LIVE && !this.core.activePlayback.dvrEnabled) {
222
+ this.resetPlaybackRate();
230
223
  } else {
231
224
  this.setSelectedRate(this.selectedRate);
232
225
  }
233
226
  }
234
227
 
228
+ private resetPlaybackRate() {
229
+ this.setSelectedRate(DEFAULT_PLAYBACK_RATE);
230
+ }
231
+
235
232
  private onStop() {
236
233
  }
237
234
 
@@ -252,37 +249,24 @@ export class PlaybackRate extends UICorePlugin {
252
249
  arrowLeftIcon,
253
250
  checkIcon,
254
251
  }));
255
-
256
- this.core.mediaControl.$el?.find('.gear-wrapper').html(this.el);
252
+ (this.core.getPlugin('bottom_gear') as BottomGear)?.setContent(this.el);
257
253
  this.highlightCurrentRate();
258
254
  }
259
255
 
260
256
  private goBack() {
261
- this.core.trigger('gear:refresh');
262
- }
263
-
264
- private updatePlaybackRate(rate: string) {
265
- this.setSelectedRate(rate);
257
+ setTimeout(() => {
258
+ this.core.getPlugin('bottom_gear').refresh()
259
+ }, 0);
266
260
  }
267
261
 
268
262
  private setSelectedRate(rate: string) {
269
263
  // Set <video playbackRate="..."
270
- this.core.$el.find('video,audio').get(0).playbackRate = rate;
264
+ this.core.activePlayback?.setPlaybackRate(rate);
271
265
  this.selectedRate = rate;
272
- // TODO
273
- // Player.player.trigger('playbackRateChanged', rate);
274
266
  }
275
267
 
276
268
  private getTitle() {
277
- let title = this.selectedRate;
278
-
279
- this.playbackRates.forEach((r) => {
280
- if (r.value === this.selectedRate) {
281
- title = r.label;
282
- }
283
- });
284
-
285
- return title;
269
+ return this.playbackRates.find((r) => r.value === this.selectedRate)?.label || this.selectedRate;
286
270
  }
287
271
 
288
272
  private highlightCurrentRate() {
@@ -14,14 +14,14 @@ import {
14
14
  import { trace } from '@gcorevideo/utils'
15
15
 
16
16
  import { CLAPPR_VERSION } from '../../build.js'
17
- import type { ZeptoResult } from '../../utils/types.js'
17
+ import type { ZeptoResult } from '../../types.js'
18
18
 
19
19
  import '../../../assets/poster/poster.scss'
20
20
  import posterHTML from '../../../assets/poster/poster.ejs'
21
21
  import playIcon from '../../../assets/icons/new/play.svg'
22
22
  import { PlaybackError } from '../../playback.types.js'
23
23
 
24
- const T = 'plugins.poster_custom'
24
+ const T = 'plugins.poster'
25
25
 
26
26
  /**
27
27
  * Displays a poster image in the background and a big play button on top when playback is stopped
@@ -65,7 +65,7 @@ export class Poster extends UIContainerPlugin {
65
65
  * @internal
66
66
  */
67
67
  get name() {
68
- return 'poster_custom'
68
+ return 'poster'
69
69
  }
70
70
 
71
71
  /**
@@ -9,7 +9,7 @@ import { CLAPPR_VERSION } from '../../build.js';
9
9
 
10
10
  import seekTimeHTML from '../../../assets/seek-time/seek-time.html';
11
11
  import '../../../assets/seek-time/seek-time.scss';
12
- import { ZeptoResult } from '../../utils/types.js';
12
+ import { ZeptoResult } from '../../types.js';
13
13
 
14
14
  const { formatTime } = Utils;
15
15
 
@@ -10,7 +10,8 @@ import fbIcon from '../../../assets/icons/old/fb.svg';
10
10
  import twIcon from '../../../assets/icons/old/twitter.svg';
11
11
 
12
12
  /**
13
- * The plugin adds a share button to the media control UI.
13
+ * PLUGIN that adds a share button to the media control UI.
14
+ * @beta
14
15
  */
15
16
  export class Share extends UICorePlugin {
16
17
  private hide = false;
@@ -8,7 +8,8 @@ import '../../../assets/skip-time/style.scss';
8
8
  type Position = 'mid' | 'left' | 'right';
9
9
 
10
10
  /**
11
- * The plugin adds skip controls to the media control UI.
11
+ * PLUGIN that adds skip controls to the media control UI.
12
+ * @beta
12
13
  */
13
14
  export class SkipTime extends UICorePluginOriginal {
14
15
  get name() {
@@ -153,7 +153,7 @@ export class SourceController extends CorePlugin {
153
153
  }
154
154
  this.bindContainerEventListeners()
155
155
  if (this.active) {
156
- this.core.activeContainer?.getPlugin('poster_custom')?.disable()
156
+ this.core.activeContainer?.getPlugin('poster')?.disable()
157
157
  spinner?.show(0)
158
158
  }
159
159
  }
@@ -177,7 +177,7 @@ export class SourceController extends CorePlugin {
177
177
  }
178
178
  switch (error.code) {
179
179
  case PlaybackErrorCode.MediaSourceUnavailable:
180
- this.core.activeContainer?.getPlugin('poster_custom')?.disable()
180
+ this.core.activeContainer?.getPlugin('poster')?.disable()
181
181
  this.retryPlayback()
182
182
  break
183
183
  default:
@@ -192,7 +192,7 @@ export class SourceController extends CorePlugin {
192
192
  })
193
193
  if (this.active) {
194
194
  this.reset()
195
- this.core.activeContainer?.getPlugin('poster_custom')?.enable()
195
+ this.core.activeContainer?.getPlugin('poster')?.enable()
196
196
  this.core.activeContainer?.getPlugin('spinner')?.hide()
197
197
  }
198
198
  })
@@ -116,7 +116,7 @@ describe('SourceController', () => {
116
116
  poster = createMockPlugin()
117
117
  spinner = createSpinnerPlugin()
118
118
  core.activeContainer.getPlugin.mockImplementation((name: string) => {
119
- if (name === 'poster_custom') {
119
+ if (name === 'poster') {
120
120
  return poster
121
121
  }
122
122
  if (name === 'spinner') {
@@ -183,7 +183,7 @@ describe('SourceController', () => {
183
183
  poster = createMockPlugin()
184
184
  spinner = createSpinnerPlugin()
185
185
  core.activeContainer.getPlugin.mockImplementation((name: string) => {
186
- if (name === 'poster_custom') {
186
+ if (name === 'poster') {
187
187
  return poster
188
188
  }
189
189
  if (name === 'spinner') {
@@ -20,6 +20,7 @@ const T = 'plugins.spinner'
20
20
 
21
21
  /**
22
22
  * Custom events emitted by the plugin
23
+ * @beta
23
24
  */
24
25
  export enum SpinnerEvents {
25
26
  /**
@@ -30,10 +31,12 @@ export enum SpinnerEvents {
30
31
  }
31
32
 
32
33
  /**
33
- * Shows a pending operation indicator when playback is buffering or in other appropriate cases
34
+ * PLUGIN that shows a pending operation indicator when playback is buffering or in a similar state
34
35
  * @beta
35
36
  * @remarks
36
- * The plugin emits
37
+ * Events emitted- {@link SpinnerEvents}
38
+ * Other plugins can use {@link SpinnerThreeBounce.show | show} and {@link SpinnerThreeBounce.hide | hide} methods to
39
+ * implement custom pending/progress indication scenarios.
37
40
  */
38
41
  export class SpinnerThreeBounce extends UIContainerPlugin {
39
42
  private userShown = false
@@ -134,7 +137,7 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
134
137
  /**
135
138
  * Shows the spinner.
136
139
  *
137
- * When called, the spinner will not hide (due to its built-in logic) until {@link SpinnerThreeBounce#hide} is called
140
+ * When called, the spinner will not hide (due to its built-in logic) until {@link SpinnerThreeBounce.hide} is called
138
141
  */
139
142
  show(delay = 300) {
140
143
  trace(`${T} show`)
@@ -17,7 +17,7 @@ import comboboxHTML from '../../../assets/subtitles/combobox.ejs'
17
17
  import stringHTML from '../../../assets/subtitles/string.ejs'
18
18
 
19
19
  import { isFullscreen } from '../utils.js'
20
- import type { ZeptoResult } from '../../utils/types.js'
20
+ import type { ZeptoResult } from '../../types.js'
21
21
 
22
22
  const VERSION: string = '2.19.14'
23
23
 
@@ -77,7 +77,7 @@ export type TelemetryRecord = {
77
77
  * @param data - The telemetry record to send.
78
78
  * @beta
79
79
  */
80
- type TelemetrySendFn = (data: TelemetryRecord) => void
80
+ export type TelemetrySendFn = (data: TelemetryRecord) => void
81
81
 
82
82
  /**
83
83
  * Plugin settings
@@ -103,7 +103,7 @@ export enum TelemetryEvent {
103
103
  }
104
104
 
105
105
  /**
106
- * Collects and reports the performance statistics.
106
+ * PLUGIN that collects and reports the performance statistics.
107
107
  * @beta
108
108
  * @remarks
109
109
  * This plugin is experimental and its API is likely to change.
@@ -8,7 +8,7 @@ import { CLAPPR_VERSION } from '../../build.js'
8
8
 
9
9
  import pluginHtml from '../../../assets/thumbnails/scrub-thumbnails.ejs'
10
10
  import '../../../assets/thumbnails/style.scss'
11
- import { ZeptoResult } from '../../utils/types.js'
11
+ import { ZeptoResult } from '../../types.js'
12
12
  import { getPageX } from '../utils.js'
13
13
 
14
14
  /**
@@ -16,7 +16,8 @@ import assert from 'assert'
16
16
  import { TimePosition } from '../../playback.types.js'
17
17
 
18
18
  import { CLAPPR_VERSION } from '../../build.js'
19
- import { TimerId, ZeptoResult } from '../../utils/types.js'
19
+ import { ZeptoResult } from '../../types.js'
20
+ import { TimerId } from '../../utils/types.js'
20
21
  import RollManager from './rollmanager.js'
21
22
  import SCTEManager from './sctemanager.js'
22
23
  import { VolumeFadeEvents } from '../volume-fade/VolumeFade.js'
@@ -286,7 +287,7 @@ export class VastAds extends UICorePlugin {
286
287
 
287
288
  private onPlaybackPlay() {
288
289
  setTimeout(() => {
289
- const posterPlugin = this.container?.getPlugin('poster_custom')
290
+ const posterPlugin = this.container?.getPlugin('poster')
290
291
 
291
292
  posterPlugin?.enable()
292
293
  posterPlugin?.$el.hide()
@@ -618,7 +619,7 @@ export class VastAds extends UICorePlugin {
618
619
  this._pluginError('failed to get Clappr playback')
619
620
  }
620
621
  // Attempt to get poster plugin. (May interfere with media control)
621
- this._posterPlugin = this._container?.getPlugin('poster_custom')
622
+ this._posterPlugin = this._container?.getPlugin('poster')
622
623
 
623
624
  // Attempt to get click-to-pause plugin. (May interfere with advert click handling)
624
625
  this._clickToPausePlugin = this._container?.getPlugin(
@@ -721,7 +722,7 @@ export class VastAds extends UICorePlugin {
721
722
 
722
723
  private adsPlaying() {
723
724
  assert(this.container, 'container is not defined')
724
- const poster = this.container.getPlugin('poster_custom')
725
+ const poster = this.container.getPlugin('poster')
725
726
 
726
727
  poster && poster.disable()
727
728
  try {
@@ -3,7 +3,8 @@ import { $, Container, Core, Events, Log, Playback } from '@clappr/core';
3
3
  import { reportError } from '@gcorevideo/utils';
4
4
  import assert from 'assert';
5
5
 
6
- import type { TimerId, ZeptoResult } from '../../utils/types.js';
6
+ import type { ZeptoResult } from '../../types.js';
7
+ import type { TimerId } from '../../utils/types.js';
7
8
 
8
9
  type RollConstructorOptions = {
9
10
  core: Core;
@@ -4,7 +4,7 @@ import assert from 'assert';
4
4
 
5
5
  import LoaderXML from './loaderxml.js';
6
6
  import Roll from './roll.js';
7
- import { ZeptoResult } from '../../utils/types.js';
7
+ import { ZeptoResult } from '../../types.js';
8
8
  import { AdRollDesc, AdRollItem, AdRollType, VastAdsOptions } from './types.js';
9
9
 
10
10
  type CoreOptions = Record<string, unknown>;
@@ -71,7 +71,7 @@ export default class RollManager extends Events {
71
71
  this.$areaClick = $areaClick;
72
72
  this._playback = this.core.activePlayback;
73
73
  this._contentElement = this._playback.el as HTMLMediaElement;
74
- this._posterPlugin = this._container.getPlugin('poster_custom');
74
+ this._posterPlugin = this._container.getPlugin('poster');
75
75
  this._clickToPausePlugin = this._container.getPlugin('click_to_pause_custom');
76
76
  this._adContainer = _adContainer;
77
77
  this._events = {};
@@ -210,7 +210,7 @@ export default class RollManager extends Events {
210
210
  //чтобы реклама шла одна за другой
211
211
  this._allURLRequest = !!roll.oneByOne;
212
212
  try {
213
- const customPosterPlugin = this.container.getPlugin('poster_custom');
213
+ const customPosterPlugin = this.container.getPlugin('poster');
214
214
 
215
215
  customPosterPlugin.hidePlayButton();
216
216
  } catch (error) {
package/src/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { $, Container, Core } from "@clappr/core";
2
+
1
3
  /**
2
4
  * Describes a media source with its MIME type and URL.
3
5
  *
@@ -61,17 +63,28 @@ export type TransportPreference = MediaTransport
61
63
  * {@link https://clappr.github.io/classes/ContainerPlugin.html}
62
64
  */
63
65
  export type PlayerPlugin = {
64
- new (...args: any[]): unknown
65
66
  name: string
66
67
  }
67
68
 
69
+ /**
70
+ * @beta
71
+ */
68
72
  export type PlayerPluginConstructor = CorePluginConstructor | ContainerPluginConstructor
69
- export type CorePluginConstructor = ((core: unknown) => PlayerPlugin) & {
70
- type: 'core'
73
+
74
+ /**
75
+ * @beta
76
+ */
77
+ export type CorePluginConstructor = {
78
+ new (core: Core): PlayerPlugin
79
+ type: string // 'core', but it's a nuisance to type it in the plugins definition
71
80
  }
72
81
 
73
- export type ContainerPluginConstructor = ((container: unknown) => PlayerPlugin) & {
74
- type: 'container'
82
+ /**
83
+ * @beta
84
+ */
85
+ export type ContainerPluginConstructor = {
86
+ new (container: Container): PlayerPlugin
87
+ type: string // 'container', but it's a nuisance to type it in the plugins definition
75
88
  }
76
89
 
77
90
  /**
@@ -289,3 +302,9 @@ export enum PlayerEvent {
289
302
  */
290
303
  VolumeUpdate = 'volumeupdate',
291
304
  }
305
+
306
+ /**
307
+ * {@link https://zeptojs.com/#$() | Zepto query result}
308
+ * @beta
309
+ */
310
+ export type ZeptoResult = ReturnType<typeof $>;
@@ -1,11 +1,3 @@
1
- import { $ } from "@clappr/core";
2
-
3
- /**
4
- * {@link https://zeptojs.com/#$() | Zepto query result}
5
- * @beta
6
- */
7
- export type ZeptoResult = ReturnType<typeof $>;
8
-
9
1
  /**
10
2
  * @internal
11
3
  */