@gcorevideo/player 2.19.12 → 2.19.14

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 (171) hide show
  1. package/dist/core.js +16 -11
  2. package/dist/index.css +1405 -1405
  3. package/dist/index.js +1239 -1088
  4. package/dist/player.d.ts +209 -45
  5. package/dist/plugins/index.css +1461 -1461
  6. package/dist/plugins/index.js +4005 -3858
  7. package/docs/api/player.bottomgear.md +3 -289
  8. package/docs/api/player.dvrcontrols._constructor_.md +3 -0
  9. package/docs/api/player.dvrcontrols.md +10 -201
  10. package/docs/api/player.levelselector.md +8 -140
  11. package/docs/api/player.md +9 -5
  12. package/docs/api/player.mediacontrol.disable.md +2 -0
  13. package/docs/api/player.mediacontrol.disabledcontrolbutton.md +1 -1
  14. package/docs/api/player.mediacontrol.enable.md +2 -0
  15. package/docs/api/player.mediacontrol.enablecontrolbutton.md +1 -1
  16. package/docs/api/player.mediacontrol.getelement.md +19 -1
  17. package/docs/api/player.mediacontrol.md +17 -281
  18. package/docs/api/player.mediacontrol.volume.md +2 -2
  19. package/docs/api/player.mediacontrolelement.md +2 -1
  20. package/docs/api/player.poster.disable.md +5 -0
  21. package/docs/api/player.poster.enable.md +5 -0
  22. package/docs/api/player.poster.md +25 -183
  23. package/lib/Player.d.ts +1 -0
  24. package/lib/Player.d.ts.map +1 -1
  25. package/lib/Player.js +15 -10
  26. package/lib/index.d.ts +1 -0
  27. package/lib/index.d.ts.map +1 -1
  28. package/lib/index.js +1 -0
  29. package/lib/plugins/audio-selector/AudioSelector.js +2 -2
  30. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  31. package/lib/plugins/big-mute-button/BigMuteButton.js +2 -1
  32. package/lib/plugins/bottom-gear/BottomGear.d.ts +38 -7
  33. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  34. package/lib/plugins/bottom-gear/BottomGear.js +53 -33
  35. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +1 -1
  36. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
  37. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +20 -24
  38. package/lib/plugins/clappr-stats/ClapprStats.js +1 -1
  39. package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
  40. package/lib/plugins/clips/Clips.js +2 -2
  41. package/lib/plugins/context-menu/ContextMenu.js +1 -1
  42. package/lib/plugins/disable-controls/DisableControls.js +1 -1
  43. package/lib/plugins/dvr-controls/DvrControls.d.ts +30 -4
  44. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
  45. package/lib/plugins/dvr-controls/DvrControls.js +39 -11
  46. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
  47. package/lib/plugins/error-screen/ErrorScreen.js +2 -1
  48. package/lib/plugins/favicon/Favicon.js +1 -1
  49. package/lib/plugins/google-analytics/GoogleAnalytics.js +1 -1
  50. package/lib/plugins/level-selector/LevelSelector.d.ts +25 -6
  51. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  52. package/lib/plugins/level-selector/LevelSelector.js +33 -12
  53. package/lib/plugins/logo/Logo.js +1 -1
  54. package/lib/plugins/media-control/MediaControl.d.ts +66 -22
  55. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  56. package/lib/plugins/media-control/MediaControl.js +72 -35
  57. package/lib/plugins/multi-camera/MultiCamera.js +3 -3
  58. package/lib/plugins/picture-in-picture/PictureInPicture.js +3 -3
  59. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  60. package/lib/plugins/playback-rate/PlaybackRate.js +3 -3
  61. package/lib/plugins/poster/Poster.d.ts +57 -3
  62. package/lib/plugins/poster/Poster.d.ts.map +1 -1
  63. package/lib/plugins/poster/Poster.js +57 -9
  64. package/lib/plugins/seek-time/SeekTime.js +2 -2
  65. package/lib/plugins/share/Share.js +2 -2
  66. package/lib/plugins/skip-time/SkipTime.js +1 -1
  67. package/lib/plugins/source-controller/SourceController.js +1 -1
  68. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +1 -1
  69. package/lib/plugins/statistics/Statistics.js +1 -1
  70. package/lib/plugins/subtitles/Subtitles.js +3 -3
  71. package/lib/plugins/thumbnails/Thumbnails.js +3 -3
  72. package/lib/plugins/types.d.ts +1 -7
  73. package/lib/plugins/types.d.ts.map +1 -1
  74. package/lib/plugins/vast-ads/VastAds.d.ts +1 -0
  75. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -1
  76. package/lib/plugins/vast-ads/VastAds.js +6 -3
  77. package/package.json +2 -1
  78. package/src/Player.ts +15 -9
  79. package/src/__tests__/Player.test.ts +15 -76
  80. package/src/index.ts +1 -0
  81. package/src/plugins/audio-selector/AudioSelector.ts +2 -2
  82. package/src/plugins/big-mute-button/BigMuteButton.ts +2 -1
  83. package/src/plugins/bottom-gear/BottomGear.ts +67 -42
  84. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +21 -26
  85. package/src/plugins/clappr-stats/ClapprStats.ts +1 -1
  86. package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
  87. package/src/plugins/clips/Clips.ts +2 -2
  88. package/src/plugins/context-menu/ContextMenu.ts +1 -1
  89. package/src/plugins/disable-controls/DisableControls.ts +1 -1
  90. package/src/plugins/dvr-controls/DvrControls.ts +42 -14
  91. package/src/plugins/error-screen/ErrorScreen.ts +2 -1
  92. package/src/plugins/favicon/Favicon.ts +1 -1
  93. package/src/plugins/google-analytics/GoogleAnalytics.ts +1 -1
  94. package/src/plugins/level-selector/LevelSelector.ts +34 -14
  95. package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +22 -2
  96. package/src/plugins/logo/Logo.ts +1 -1
  97. package/src/plugins/media-control/MediaControl.ts +83 -44
  98. package/src/plugins/multi-camera/MultiCamera.ts +3 -3
  99. package/src/plugins/picture-in-picture/PictureInPicture.ts +3 -3
  100. package/src/plugins/playback-rate/PlaybackRate.ts +3 -4
  101. package/src/plugins/poster/Poster.ts +59 -12
  102. package/src/plugins/seek-time/SeekTime.ts +2 -2
  103. package/src/plugins/share/Share.ts +2 -2
  104. package/src/plugins/skip-time/SkipTime.ts +1 -1
  105. package/src/plugins/source-controller/SourceController.ts +1 -1
  106. package/src/plugins/source-controller/__tests__/SourceController.test.ts +5 -0
  107. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +1 -1
  108. package/src/plugins/statistics/Statistics.ts +1 -1
  109. package/src/plugins/subtitles/Subtitles.ts +3 -3
  110. package/src/plugins/thumbnails/Thumbnails.ts +3 -3
  111. package/src/plugins/types.ts +1 -0
  112. package/src/plugins/vast-ads/VastAds.ts +6 -6
  113. package/temp/player.api.json +3301 -5030
  114. package/tsconfig.tsbuildinfo +1 -1
  115. package/docs/api/player.bottomgear.attributes.md +0 -17
  116. package/docs/api/player.bottomgear.bindevents.md +0 -18
  117. package/docs/api/player.bottomgear.container.md +0 -14
  118. package/docs/api/player.bottomgear.events.md +0 -16
  119. package/docs/api/player.bottomgear.hide.md +0 -18
  120. package/docs/api/player.bottomgear.name.md +0 -14
  121. package/docs/api/player.bottomgear.refresh.md +0 -18
  122. package/docs/api/player.bottomgear.reload.md +0 -18
  123. package/docs/api/player.bottomgear.render.md +0 -18
  124. package/docs/api/player.bottomgear.supportedversion.md +0 -16
  125. package/docs/api/player.bottomgear.template.md +0 -14
  126. package/docs/api/player.bottomgear.togglegearmenu.md +0 -18
  127. package/docs/api/player.bottomgear.unbindevents.md +0 -18
  128. package/docs/api/player.bottomgear.version.md +0 -14
  129. package/docs/api/player.dvrcontrols.attributes.md +0 -14
  130. package/docs/api/player.dvrcontrols.bindevents.md +0 -15
  131. package/docs/api/player.dvrcontrols.click.md +0 -15
  132. package/docs/api/player.dvrcontrols.events.md +0 -13
  133. package/docs/api/player.dvrcontrols.name.md +0 -11
  134. package/docs/api/player.dvrcontrols.render.md +0 -15
  135. package/docs/api/player.dvrcontrols.settingsupdate.md +0 -15
  136. package/docs/api/player.dvrcontrols.shouldrender.md +0 -15
  137. package/docs/api/player.dvrcontrols.supportedversion.md +0 -13
  138. package/docs/api/player.dvrcontrols.template.md +0 -11
  139. package/docs/api/player.levelselector.attributes.md +0 -17
  140. package/docs/api/player.levelselector.bindevents.md +0 -18
  141. package/docs/api/player.levelselector.name.md +0 -14
  142. package/docs/api/player.levelselector.render.md +0 -18
  143. package/docs/api/player.levelselector.supportedversion.md +0 -16
  144. package/docs/api/player.levelselector.version.md +0 -14
  145. package/docs/api/player.mediacontrol.attributes.md +0 -17
  146. package/docs/api/player.mediacontrol.bindcontainerevents.md +0 -18
  147. package/docs/api/player.mediacontrol.bindevents.md +0 -18
  148. package/docs/api/player.mediacontrol.container.md +0 -14
  149. package/docs/api/player.mediacontrol.destroy.md +0 -18
  150. package/docs/api/player.mediacontrol.disabled.md +0 -14
  151. package/docs/api/player.mediacontrol.events.md +0 -40
  152. package/docs/api/player.mediacontrol.getexternalinterface.md +0 -21
  153. package/docs/api/player.mediacontrol.name.md +0 -14
  154. package/docs/api/player.mediacontrol.pause.md +0 -20
  155. package/docs/api/player.mediacontrol.play.md +0 -20
  156. package/docs/api/player.mediacontrol.playback.md +0 -14
  157. package/docs/api/player.mediacontrol.render.md +0 -18
  158. package/docs/api/player.mediacontrol.setmuted.md +0 -52
  159. package/docs/api/player.mediacontrol.stop.md +0 -20
  160. package/docs/api/player.mediacontrol.supportedversion.md +0 -16
  161. package/docs/api/player.poster.attributes.md +0 -14
  162. package/docs/api/player.poster.bindevents.md +0 -15
  163. package/docs/api/player.poster.destroy.md +0 -15
  164. package/docs/api/player.poster.events.md +0 -13
  165. package/docs/api/player.poster.name.md +0 -11
  166. package/docs/api/player.poster.render.md +0 -15
  167. package/docs/api/player.poster.shouldrender.md +0 -11
  168. package/docs/api/player.poster.showonvideoend.md +0 -11
  169. package/docs/api/player.poster.supportedversion.md +0 -13
  170. package/docs/api/player.poster.template.md +0 -11
  171. package/src/plugins/build.ts +0 -1
@@ -43,6 +43,7 @@ describe('LevelSelector', () => {
43
43
  beforeEach(() => {
44
44
  const activeContainer = createContainer()
45
45
  activePlayback = createPlayback()
46
+ let mediaControl: UICorePlugin | null = null
46
47
  core = Object.assign(new EventLite(), {
47
48
  activeContainer,
48
49
  activePlayback,
@@ -52,8 +53,14 @@ describe('LevelSelector', () => {
52
53
  labels: { 360: '360p', 720: 'HD' },
53
54
  },
54
55
  },
56
+ getPlugin: vi.fn().mockImplementation((name: string) => {
57
+ if (name === 'media_control') {
58
+ return mediaControl
59
+ }
60
+ return null
61
+ }),
55
62
  })
56
- core.mediaControl = new UICorePlugin(core)
63
+ mediaControl = createMediaControl(core)
57
64
  levelSelector = new LevelSelector(core)
58
65
  })
59
66
  describe('initially', () => {
@@ -110,6 +117,7 @@ describe('LevelSelector', () => {
110
117
  beforeEach(() => {
111
118
  const activeContainer = createContainer()
112
119
  activePlayback = createPlayback()
120
+ let mediaControl: UICorePlugin | null = null
113
121
  core = Object.assign(new EventLite(), {
114
122
  activeContainer,
115
123
  activePlayback,
@@ -119,8 +127,14 @@ describe('LevelSelector', () => {
119
127
  labels: { 360: '360p', 720: '720p' },
120
128
  },
121
129
  },
130
+ getPlugin: vi.fn().mockImplementation((name: string) => {
131
+ if (name === 'media_control') {
132
+ return mediaControl
133
+ }
134
+ return null
135
+ }),
122
136
  })
123
- core.mediaControl = new UICorePlugin(core)
137
+ mediaControl = createMediaControl(core)
124
138
  levelSelector = new LevelSelector(core)
125
139
  })
126
140
  describe('basically', () => {
@@ -218,3 +232,9 @@ expect.extend({
218
232
  }
219
233
  }
220
234
  })
235
+
236
+ function createMediaControl(core: any) {
237
+ const mediaControl = new UICorePlugin(core)
238
+ mediaControl.getElement = vi.fn().mockReturnValue(null)
239
+ return mediaControl
240
+ }
@@ -1,6 +1,6 @@
1
1
  import { UIContainerPlugin, Events, template as t, Container } from '@clappr/core';
2
2
 
3
- import { CLAPPR_VERSION } from '../build.js';
3
+ import { CLAPPR_VERSION } from '../../build.js';
4
4
  import { calculateSize } from './utils/index.js';
5
5
  import { ZeptoResult } from '../../utils/types.js';
6
6
 
@@ -13,12 +13,12 @@ import {
13
13
  $,
14
14
  Core,
15
15
  } from '@clappr/core'
16
- import { reportError } from '@gcorevideo/utils';
16
+ import { reportError } from '@gcorevideo/utils'
17
17
  import { type TimeProgress } from '../../playback.types.js'
18
18
 
19
19
  import { Kibo } from '../kibo/index.js'
20
20
 
21
- import { CLAPPR_VERSION } from '../build.js'
21
+ import { CLAPPR_VERSION } from '../../build.js'
22
22
  import { ZeptoResult } from '../../utils/types.js'
23
23
  import { getPageX, isFullscreen } from '../utils.js'
24
24
 
@@ -35,9 +35,16 @@ import fullscreenOffIcon from '../../../assets/icons/new/fullscreen-off.svg'
35
35
  import fullscreenOnIcon from '../../../assets/icons/new/fullscreen-on.svg'
36
36
 
37
37
  /**
38
+ * Media control elements, mount points for additional plugins
38
39
  * @beta
39
40
  */
40
- export type MediaControlElement = 'clipText' | 'pip' | 'seekBarContainer'
41
+ export type MediaControlElement =
42
+ | 'bottomGear' // an alias of gear
43
+ | 'clipText'
44
+ | 'gear'
45
+ | 'pip'
46
+ | 'playbackRate'
47
+ | 'seekBarContainer'
41
48
 
42
49
  const T = 'plugins.media_control'
43
50
 
@@ -67,11 +74,17 @@ type DisabledClickable = {
67
74
  }
68
75
 
69
76
  /**
70
- * The MediaControl is responsible for displaying the Player controls.
77
+ * The MediaControl provides a foundation for developing custom media controls UI.
71
78
  * @beta
72
79
  * @remarks
73
- * This plugin provides a foundation for developing a media controls UI via additional plugins.
74
80
  * The methods exposed are to be used by the other plugins that extend the media control UI.
81
+ * The plugin registration should be arranged so that MediaControl is initialized before every other plugin that depends on it.
82
+ * @example
83
+ * ```ts
84
+ * Player.registerPlugin(MediaControl) // <--- This must go first
85
+ * Player.registerPlugin(LevelSelector) // a media control plugin
86
+ * Player.registerPlugin(NerdStats) // another media control plugin
87
+ * ```
75
88
  */
76
89
  export class MediaControl extends UICorePlugin {
77
90
  private advertisementPlaying = false
@@ -112,8 +125,6 @@ export class MediaControl extends UICorePlugin {
112
125
 
113
126
  private settings: Record<string, unknown> = {}
114
127
 
115
- private svgMask: ZeptoResult | null = null
116
-
117
128
  private userDisabled = false
118
129
 
119
130
  private userKeepVisible = false
@@ -170,29 +181,46 @@ export class MediaControl extends UICorePlugin {
170
181
 
171
182
  private static readonly template = template(mediaControlHTML)
172
183
 
184
+ /**
185
+ * @internal
186
+ */
173
187
  get name() {
174
188
  return 'media_control'
175
189
  }
176
190
 
191
+ /**
192
+ * @internal
193
+ */
177
194
  get supportedVersion() {
178
195
  return { min: CLAPPR_VERSION }
179
196
  }
180
197
 
181
- get disabled() {
198
+ private get disabled() {
182
199
  const playbackIsNOOP =
183
200
  this.container && this.container.getPlaybackType() === Playback.NO_OP
184
201
 
185
202
  return this.userDisabled || playbackIsNOOP
186
203
  }
187
204
 
205
+ /**
206
+ * @internal
207
+ * @deprecated
208
+ */
188
209
  get container() {
189
210
  return this.core && this.core.activeContainer
190
211
  }
191
212
 
213
+ /**
214
+ * @internal
215
+ * @deprecated
216
+ */
192
217
  get playback() {
193
218
  return this.core && this.core.activePlayback
194
219
  }
195
220
 
221
+ /**
222
+ * @internal
223
+ */
196
224
  override get attributes() {
197
225
  return {
198
226
  class: 'media-control-skin-1',
@@ -200,6 +228,9 @@ export class MediaControl extends UICorePlugin {
200
228
  }
201
229
  }
202
230
 
231
+ /**
232
+ * @internal
233
+ */
203
234
  override get events() {
204
235
  return {
205
236
  'click [data-play]': 'play',
@@ -231,11 +262,11 @@ export class MediaControl extends UICorePlugin {
231
262
  }
232
263
 
233
264
  /**
234
- * Current volume
265
+ * Current volume [0..100]
235
266
  */
236
- get volume() {
237
- return this.container && this.container.isReady
238
- ? this.container.volume
267
+ get volume(): number {
268
+ return this.core.activeContainer?.isReady
269
+ ? this.core.activeContainer.volume
239
270
  : this.intendedVolume
240
271
  }
241
272
 
@@ -256,7 +287,6 @@ export class MediaControl extends UICorePlugin {
256
287
 
257
288
  this.userDisabled = false
258
289
  if (
259
- (this.container && this.container.mediaControlDisabled) ||
260
290
  this.options.chromeless
261
291
  ) {
262
292
  this.disable()
@@ -269,6 +299,9 @@ export class MediaControl extends UICorePlugin {
269
299
  $(document).bind('touchmove', this.updateDrag)
270
300
  }
271
301
 
302
+ /**
303
+ * @internal
304
+ */
272
305
  override getExternalInterface() {
273
306
  return {
274
307
  setVolume: this.setVolume,
@@ -276,6 +309,9 @@ export class MediaControl extends UICorePlugin {
276
309
  }
277
310
  }
278
311
 
312
+ /**
313
+ * @internal
314
+ */
279
315
  override bindEvents() {
280
316
  // @ts-ignore
281
317
  this.stopListening()
@@ -318,7 +354,7 @@ export class MediaControl extends UICorePlugin {
318
354
  // }
319
355
  }
320
356
 
321
- bindContainerEvents() {
357
+ private bindContainerEvents() {
322
358
  if (!this.container) {
323
359
  return
324
360
  }
@@ -382,6 +418,9 @@ export class MediaControl extends UICorePlugin {
382
418
  }
383
419
  }
384
420
 
421
+ /**
422
+ * Disables the plugin and unmounts its UI
423
+ */
385
424
  override disable() {
386
425
  this.userDisabled = true
387
426
  this.hide()
@@ -389,6 +428,9 @@ export class MediaControl extends UICorePlugin {
389
428
  this.$el.hide()
390
429
  }
391
430
 
431
+ /**
432
+ * Reenables the plugin disabled earlier with the {@link MediaControl.disable} method
433
+ */
392
434
  override enable() {
393
435
  if (this.options.chromeless) {
394
436
  return
@@ -398,27 +440,6 @@ export class MediaControl extends UICorePlugin {
398
440
  this.show()
399
441
  }
400
442
 
401
- /**
402
- * Start the playback
403
- */
404
- play() {
405
- this.container && this.container.play()
406
- }
407
-
408
- /**
409
- * Pause the playback
410
- */
411
- pause() {
412
- this.container && this.container.pause()
413
- }
414
-
415
- /**
416
- * Stop the playback
417
- */
418
- stop() {
419
- this.container && this.container.stop()
420
- }
421
-
422
443
  /**
423
444
  * Set the initial volume, which is preserved when playback is interrupted by an advertisement
424
445
  */
@@ -1053,14 +1074,32 @@ export class MediaControl extends UICorePlugin {
1053
1074
  /**
1054
1075
  * Get a media control element DOM node
1055
1076
  * @param name - The name of the media control element
1056
- * @returns The DOM node to render the media control element
1077
+ * @returns The DOM node to render to or extend
1078
+ * @remarks
1079
+ * Use this method to render custom media control UI in a plugin
1080
+ * @example
1081
+ * ```ts
1082
+ * class MyPlugin extends UICorePlugin {
1083
+ * override render() {
1084
+ * const mediaControl = this.core.getPlugin('media_control')
1085
+ * const clipText = mediaControl.getElement('clipText')
1086
+ * clipText?.el.text('Here we go')
1087
+ * return this
1088
+ * }
1089
+ * }
1090
+ * ```
1057
1091
  */
1058
1092
  getElement(name: MediaControlElement): ZeptoResult | null {
1059
1093
  switch (name) {
1060
1094
  case 'clipText':
1061
1095
  return this.$clipText
1096
+ case 'bottomGear':
1097
+ case 'gear':
1098
+ return this.$bottomGear
1062
1099
  case 'pip':
1063
1100
  return this.$pip
1101
+ case 'playbackRate':
1102
+ return this.$playbackRate
1064
1103
  case 'seekBarContainer':
1065
1104
  return this.$seekBarContainer
1066
1105
  }
@@ -1223,6 +1262,9 @@ export class MediaControl extends UICorePlugin {
1223
1262
  $(element).find('svg path').css({ fill: this.buttonsColor })
1224
1263
  }
1225
1264
 
1265
+ /**
1266
+ * @internal
1267
+ */
1226
1268
  override destroy() {
1227
1269
  $(document).unbind('mouseup', this.stopDrag)
1228
1270
  $(document).unbind('mousemove', this.updateDrag)
@@ -1237,6 +1279,9 @@ export class MediaControl extends UICorePlugin {
1237
1279
  this.trigger(Events.MEDIACONTROL_OPTIONS_CHANGE)
1238
1280
  }
1239
1281
 
1282
+ /**
1283
+ * @internal
1284
+ */
1240
1285
  override render() {
1241
1286
  const timeout = this.options.hideMediaControlDelay || 2000
1242
1287
 
@@ -1343,11 +1388,6 @@ export class MediaControl extends UICorePlugin {
1343
1388
  }
1344
1389
  }
1345
1390
 
1346
- // TODO
1347
- setMuted(value: boolean) {
1348
- this.container.options.mute = value
1349
- }
1350
-
1351
1391
  private static getPageX(event: MouseEvent | TouchEvent): number {
1352
1392
  return getPageX(event)
1353
1393
  }
@@ -1367,7 +1407,7 @@ export class MediaControl extends UICorePlugin {
1367
1407
  }
1368
1408
 
1369
1409
  /**
1370
- * Enable the control button
1410
+ * Enable the user interaction disabled earlier
1371
1411
  */
1372
1412
  enableControlButton() {
1373
1413
  this.disabledClickableList.forEach((element) => {
@@ -1376,7 +1416,7 @@ export class MediaControl extends UICorePlugin {
1376
1416
  }
1377
1417
 
1378
1418
  /**
1379
- * Disable the control button
1419
+ * Disable the user interaction for the control buttons
1380
1420
  */
1381
1421
  disabledControlButton() {
1382
1422
  this.disabledClickableList.forEach((element) => {
@@ -1393,7 +1433,6 @@ export class MediaControl extends UICorePlugin {
1393
1433
  }
1394
1434
  }
1395
1435
 
1396
- // TODO drop?
1397
1436
  MediaControl.extend = function (properties) {
1398
1437
  return extend(MediaControl, properties)
1399
1438
  }
@@ -1,7 +1,7 @@
1
1
  import { Browser, Core, Events, Playback, template, UICorePlugin } from '@clappr/core';
2
2
  import { reportError, trace } from '@gcorevideo/utils';
3
3
 
4
- import { CLAPPR_VERSION } from '../build.js';
4
+ import { CLAPPR_VERSION } from '../../build.js';
5
5
 
6
6
  import pluginHtml from '../../../assets/multi-camera/multicamera.ejs';
7
7
  import '../../../assets/multi-camera/style.scss';
@@ -23,7 +23,7 @@ type MediaSourceInfo = {
23
23
 
24
24
  const VERSION = '0.0.1';
25
25
 
26
- const T = 'plugins.multicamera';
26
+ const T = 'plugins.media_control_multicamera';
27
27
 
28
28
  export class MultiCamera extends UICorePlugin {
29
29
  private currentCamera: MediaSourceInfo | null = null;
@@ -37,7 +37,7 @@ export class MultiCamera extends UICorePlugin {
37
37
  private noActiveStreams = false;
38
38
 
39
39
  get name() {
40
- return 'multicamera';
40
+ return 'media_control_multicamera';
41
41
  }
42
42
 
43
43
  get supportedVersion() {
@@ -1,7 +1,7 @@
1
1
  import { UICorePlugin, template, Events } from '@clappr/core';
2
2
  import { trace } from '@gcorevideo/utils';
3
3
 
4
- import { CLAPPR_VERSION } from '../build.js';
4
+ import { CLAPPR_VERSION } from '../../build.js';
5
5
 
6
6
  import pipIcon from '../../../assets/icons/new/pip.svg';
7
7
  import buttonHtml from '../../../assets/picture-in-picture/button.ejs';
@@ -9,11 +9,11 @@ import '../../../assets/picture-in-picture/button.scss';
9
9
 
10
10
  const VERSION = '0.0.1';
11
11
 
12
- const T = `plugins.picture_in_picture`;
12
+ const T = `plugins.media_control_pip`;
13
13
 
14
14
  export class PictureInPicture extends UICorePlugin {
15
15
  get name() {
16
- return 'picture_in_picture';
16
+ return 'media_control_pip';
17
17
  }
18
18
 
19
19
  get supportedVersion() {
@@ -1,6 +1,6 @@
1
1
  import { Events, UICorePlugin, Playback, template } from '@clappr/core';
2
2
 
3
- import { CLAPPR_VERSION } from '../build.js';
3
+ import { CLAPPR_VERSION } from '../../build.js';
4
4
  import type { ZeptoResult } from '../../utils/types.js';
5
5
 
6
6
  import pluginHtml from '../../../assets/playback-rate/playback-rate-selector.ejs';
@@ -28,6 +28,7 @@ const DEFAULT_PLAYBACK_RATES = [
28
28
 
29
29
  const DEFAULT_PLAYBACK_RATE = '1.0';
30
30
 
31
+ // TODO
31
32
  const MEDIACONTROL_PLAYBACKRATE = 'playbackRate';
32
33
 
33
34
  export class PlaybackRate extends UICorePlugin {
@@ -40,7 +41,7 @@ export class PlaybackRate extends UICorePlugin {
40
41
  private selectedRate: string = DEFAULT_PLAYBACK_RATE;
41
42
 
42
43
  get name() {
43
- return 'playback_rate';
44
+ return 'media_control_playback_rate';
44
45
  }
45
46
 
46
47
  get supportedVersion() {
@@ -265,5 +266,3 @@ export class PlaybackRate extends UICorePlugin {
265
266
  currentLevelElement.find('a').addClass('gcore-skin-active');
266
267
  }
267
268
  }
268
-
269
- // PlaybackRate.MEDIACONTROL_PLAYBACKRATE = 'playbackRate';
@@ -13,7 +13,7 @@ import {
13
13
  } from '@clappr/core'
14
14
  import { trace } from '@gcorevideo/utils'
15
15
 
16
- import { CLAPPR_VERSION } from '../build.js'
16
+ import { CLAPPR_VERSION } from '../../build.js'
17
17
  import type { ZeptoResult } from '../../utils/types.js'
18
18
 
19
19
  import '../../../assets/poster/poster.scss'
@@ -23,6 +23,33 @@ import { PlaybackError } from '../../playback.types.js'
23
23
 
24
24
  const T = 'plugins.poster_custom'
25
25
 
26
+ /**
27
+ * Displays a poster image in the background and a big play button on top when playback is stopped
28
+ * @beta
29
+ * @remarks
30
+ * When the playback is stopped, media control UI is disabled.
31
+ *
32
+ * Configuration options:
33
+ *
34
+ * - `poster.custom` - custom CSS background
35
+ *
36
+ * - `poster.showForNoOp` - whether to show the poster when the playback is not started
37
+ *
38
+ * - `poster.url` - the URL of the poster image
39
+ *
40
+ * - `poster.showOnVideoEnd` - whether to show the poster when the playback is ended
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * new Player({
45
+ * ...
46
+ * poster: {
47
+ * showForNoOp: true,
48
+ * url: 'https://via.placeholder.com/150.png',
49
+ * }
50
+ * })
51
+ * ```
52
+ */
26
53
  export class Poster extends UIContainerPlugin {
27
54
  private hasFatalError = false
28
55
 
@@ -34,27 +61,26 @@ export class Poster extends UIContainerPlugin {
34
61
 
35
62
  private $playWrapper: ZeptoResult | null = null
36
63
 
64
+ /**
65
+ * @internal
66
+ */
37
67
  get name() {
38
68
  return 'poster_custom'
39
69
  }
40
70
 
71
+ /**
72
+ * @internal
73
+ */
41
74
  get supportedVersion() {
42
75
  return { min: CLAPPR_VERSION }
43
76
  }
44
77
 
45
- get template() {
46
- return template(posterHTML)
47
- }
78
+ private static readonly template = template(posterHTML)
48
79
 
49
- get shouldRender() {
80
+ private get shouldRender() {
50
81
  if (!this.enabled) {
51
82
  return false
52
83
  }
53
- // const showOnError = this.options.poster?.showOnError !== false
54
- trace(`${T} shouldRender`, {
55
- hasFatalError: this.hasFatalError,
56
- })
57
-
58
84
  const showForNoOp = !!this.options.poster?.showForNoOp
59
85
  return (
60
86
  this.container.playback.name !== 'html_img' &&
@@ -63,6 +89,9 @@ export class Poster extends UIContainerPlugin {
63
89
  )
64
90
  }
65
91
 
92
+ /**
93
+ * @internal
94
+ */
66
95
  override get attributes() {
67
96
  return {
68
97
  class: 'player-poster',
@@ -70,16 +99,22 @@ export class Poster extends UIContainerPlugin {
70
99
  }
71
100
  }
72
101
 
102
+ /**
103
+ * @internal
104
+ */
73
105
  override get events() {
74
106
  return {
75
107
  click: 'clicked',
76
108
  }
77
109
  }
78
110
 
79
- get showOnVideoEnd() {
111
+ private get showOnVideoEnd() {
80
112
  return this.options.poster?.showOnVideoEnd !== false
81
113
  }
82
114
 
115
+ /**
116
+ * @internal
117
+ */
83
118
  override bindEvents() {
84
119
  this.listenTo(this.container, Events.CONTAINER_STOP, this.onStop)
85
120
  this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay)
@@ -97,12 +132,18 @@ export class Poster extends UIContainerPlugin {
97
132
  this.listenTo(this.container, Events.PLAYBACK_PLAY_INTENT, this.onPlayIntent)
98
133
  }
99
134
 
135
+ /**
136
+ * Reenables earlier disabled plugin
137
+ */
100
138
  override enable() {
101
139
  super.enable()
102
140
  this.hasStartedPlaying = this.container.playback.isPlaying()
103
141
  this.update()
104
142
  }
105
143
 
144
+ /**
145
+ * Disables the plugin, unmounting it from the DOM
146
+ */
106
147
  override disable() {
107
148
  trace(`${T} disable`)
108
149
  this.hasStartedPlaying = false
@@ -252,12 +293,15 @@ export class Poster extends UIContainerPlugin {
252
293
  }
253
294
  }
254
295
 
296
+ /**
297
+ * @internal
298
+ */
255
299
  override render() {
256
300
  if (!this.shouldRender) {
257
301
  return this
258
302
  }
259
303
 
260
- this.$el.html(this.template())
304
+ this.$el.html(Poster.template())
261
305
 
262
306
  const isRegularPoster =
263
307
  this.options.poster && this.options.poster.custom === undefined
@@ -291,6 +335,9 @@ export class Poster extends UIContainerPlugin {
291
335
  return this
292
336
  }
293
337
 
338
+ /**
339
+ * @internal
340
+ */
294
341
  override destroy() {
295
342
  this.container.$el.removeClass('container-with-poster-clickable')
296
343
  return this
@@ -5,7 +5,7 @@
5
5
  import { Events, Playback, UICorePlugin, Utils, template } from '@clappr/core';
6
6
  import { TimeUpdate } from '../../playback.types.js';
7
7
 
8
- import { CLAPPR_VERSION } from '../build.js';
8
+ 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';
@@ -15,7 +15,7 @@ const { formatTime } = Utils;
15
15
 
16
16
  export class SeekTime extends UICorePlugin {
17
17
  get name() {
18
- return 'seek_time';
18
+ return 'media_control_seek_time';
19
19
  }
20
20
 
21
21
  get supportedVersion() {
@@ -1,6 +1,6 @@
1
1
  import { Container, Events, UICorePlugin, template } from '@clappr/core';
2
2
 
3
- import { CLAPPR_VERSION } from '../build.js';
3
+ import { CLAPPR_VERSION } from '../../build.js';
4
4
 
5
5
  import pluginHtml from '../../../assets/share/share.ejs';
6
6
  import '../../../assets/share/style.scss';
@@ -15,7 +15,7 @@ export class Share extends UICorePlugin {
15
15
  private container: Container | null = null;
16
16
 
17
17
  get name() {
18
- return 'share';
18
+ return 'media_control_share';
19
19
  }
20
20
 
21
21
  get supportedVersion() {
@@ -1,6 +1,6 @@
1
1
  import { UICorePlugin as UICorePluginOriginal, Browser, Playback, Events, template } from '@clappr/core';
2
2
 
3
- import { CLAPPR_VERSION } from '../build.js';
3
+ import { CLAPPR_VERSION } from '../../build.js';
4
4
 
5
5
  import pluginHtml from '../../../assets/skip-time/skip-time.ejs';
6
6
  import '../../../assets/skip-time/style.scss';
@@ -12,7 +12,7 @@ import {
12
12
  } from '../../types.js'
13
13
  import { trace } from '@gcorevideo/utils'
14
14
 
15
- import { CLAPPR_VERSION } from '../build'
15
+ import { CLAPPR_VERSION } from '../../build.js'
16
16
 
17
17
  const T = 'plugins.source_controller'
18
18