@gcorevideo/player 2.19.14 → 2.19.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/assets/level-selector/list.ejs +2 -2
  2. package/dist/core.js +1 -1
  3. package/dist/index.css +1054 -1054
  4. package/dist/index.js +1232 -1154
  5. package/dist/player.d.ts +157 -22
  6. package/dist/plugins/index.css +634 -634
  7. package/dist/plugins/index.js +1024 -944
  8. package/docs/api/player.bottomgear.getelement.md +56 -0
  9. package/docs/api/player.bottomgear.md +51 -0
  10. package/docs/api/player.bottomgear.setcontent.md +56 -0
  11. package/docs/api/{player.subtitles.levelelement.md → player.gearevents.md} +11 -13
  12. package/docs/api/{player.sourcecontroller.name.md → player.gearitemelement.md} +5 -3
  13. package/docs/api/player.levelselector.md +9 -1
  14. package/docs/api/player.md +37 -0
  15. package/docs/api/{player.sourcecontroller.supportedversion.md → player.mediacontrol.getrightpanel.md} +11 -5
  16. package/docs/api/player.mediacontrol.md +14 -0
  17. package/docs/api/player.mediacontrolelement.md +1 -1
  18. package/docs/api/player.sourcecontroller.md +0 -90
  19. package/docs/api/player.spinnerevents.md +49 -0
  20. package/docs/api/player.spinnerthreebounce._constructor_.md +3 -0
  21. package/docs/api/player.spinnerthreebounce.hide.md +5 -0
  22. package/docs/api/player.spinnerthreebounce.md +14 -95
  23. package/docs/api/player.spinnerthreebounce.show.md +6 -37
  24. package/docs/api/player.subtitles.hide.md +5 -0
  25. package/docs/api/player.subtitles.md +23 -275
  26. package/docs/api/player.subtitles.show.md +5 -0
  27. package/lib/plugins/bottom-gear/BottomGear.d.ts +20 -1
  28. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  29. package/lib/plugins/bottom-gear/BottomGear.js +28 -7
  30. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +4 -4
  31. package/lib/plugins/level-selector/LevelSelector.d.ts +10 -3
  32. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  33. package/lib/plugins/level-selector/LevelSelector.js +20 -19
  34. package/lib/plugins/media-control/MediaControl.d.ts +6 -2
  35. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  36. package/lib/plugins/media-control/MediaControl.js +40 -39
  37. package/lib/plugins/source-controller/SourceController.d.ts +9 -0
  38. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  39. package/lib/plugins/source-controller/SourceController.js +11 -1
  40. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +35 -1
  41. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  42. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +46 -23
  43. package/lib/plugins/subtitles/Subtitles.d.ts +65 -16
  44. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -1
  45. package/lib/plugins/subtitles/Subtitles.js +131 -109
  46. package/package.json +1 -1
  47. package/src/plugins/bottom-gear/BottomGear.ts +26 -4
  48. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +4 -4
  49. package/src/plugins/level-selector/LevelSelector.ts +22 -19
  50. package/src/plugins/media-control/MediaControl.ts +43 -41
  51. package/src/plugins/source-controller/SourceController.ts +11 -1
  52. package/src/plugins/source-controller/__tests__/SourceController.test.ts +1 -1
  53. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +46 -22
  54. package/src/plugins/subtitles/Subtitles.ts +146 -155
  55. package/temp/player.api.json +293 -822
  56. package/tsconfig.tsbuildinfo +1 -1
  57. package/docs/api/player.sourcecontroller.version.md +0 -14
  58. package/docs/api/player.spinnerthreebounce.attributes.md +0 -14
  59. package/docs/api/player.spinnerthreebounce.name.md +0 -11
  60. package/docs/api/player.spinnerthreebounce.render.md +0 -15
  61. package/docs/api/player.spinnerthreebounce.supportedversion.md +0 -13
  62. package/docs/api/player.subtitles.attributes.md +0 -14
  63. package/docs/api/player.subtitles.bindevents.md +0 -15
  64. package/docs/api/player.subtitles.buttonelement.md +0 -15
  65. package/docs/api/player.subtitles.events.md +0 -14
  66. package/docs/api/player.subtitles.name.md +0 -11
  67. package/docs/api/player.subtitles.preselectedlanguage.md +0 -11
  68. package/docs/api/player.subtitles.reload.md +0 -15
  69. package/docs/api/player.subtitles.render.md +0 -15
  70. package/docs/api/player.subtitles.selectsubtitles.md +0 -15
  71. package/docs/api/player.subtitles.startlevelswitch.md +0 -15
  72. package/docs/api/player.subtitles.stoplevelswitch.md +0 -15
  73. package/docs/api/player.subtitles.supportedversion.md +0 -13
  74. package/docs/api/player.subtitles.template.md +0 -11
  75. package/docs/api/player.subtitles.templatestring.md +0 -11
  76. package/docs/api/player.subtitles.unbindevents.md +0 -15
  77. package/docs/api/player.subtitles.version.md +0 -11
@@ -45,6 +45,7 @@ export type MediaControlElement =
45
45
  | 'pip'
46
46
  | 'playbackRate'
47
47
  | 'seekBarContainer'
48
+ | 'subtitlesSelector'
48
49
 
49
50
  const T = 'plugins.media_control'
50
51
 
@@ -207,7 +208,7 @@ export class MediaControl extends UICorePlugin {
207
208
  * @deprecated
208
209
  */
209
210
  get container() {
210
- return this.core && this.core.activeContainer
211
+ return this.core.activeContainer
211
212
  }
212
213
 
213
214
  /**
@@ -215,7 +216,7 @@ export class MediaControl extends UICorePlugin {
215
216
  * @deprecated
216
217
  */
217
218
  get playback() {
218
- return this.core && this.core.activePlayback
219
+ return this.core.activePlayback
219
220
  }
220
221
 
221
222
  /**
@@ -327,7 +328,6 @@ export class MediaControl extends UICorePlugin {
327
328
  this.listenTo(this.core, Events.CORE_FULLSCREEN, this.show)
328
329
  this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.configure)
329
330
  this.listenTo(this.core, Events.CORE_RESIZE, this.playerResize)
330
- this.bindContainerEvents()
331
331
 
332
332
  this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
333
333
  this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
@@ -355,63 +355,60 @@ export class MediaControl extends UICorePlugin {
355
355
  }
356
356
 
357
357
  private bindContainerEvents() {
358
- if (!this.container) {
359
- return
360
- }
361
- this.listenTo(this.container, Events.CONTAINER_PLAY, this.changeTogglePlay)
362
- this.listenTo(this.container, Events.CONTAINER_PAUSE, this.changeTogglePlay)
363
- this.listenTo(this.container, Events.CONTAINER_STOP, this.changeTogglePlay)
358
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAY, this.changeTogglePlay)
359
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_PAUSE, this.changeTogglePlay)
360
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_STOP, this.changeTogglePlay)
364
361
  this.listenTo(
365
- this.container,
362
+ this.core.activeContainer,
366
363
  Events.CONTAINER_DBLCLICK,
367
364
  this.toggleFullscreen,
368
365
  )
369
366
  this.listenTo(
370
- this.container,
367
+ this.core.activeContainer,
371
368
  Events.CONTAINER_TIMEUPDATE,
372
369
  this.onTimeUpdate,
373
370
  )
374
371
  this.listenTo(
375
- this.container,
372
+ this.core.activeContainer,
376
373
  Events.CONTAINER_PROGRESS,
377
374
  this.updateProgressBar,
378
375
  )
379
376
  this.listenTo(
380
- this.container,
377
+ this.core.activeContainer,
381
378
  Events.CONTAINER_SETTINGSUPDATE,
382
379
  this.settingsUpdate,
383
380
  )
384
381
  this.listenTo(
385
- this.container,
382
+ this.core.activeContainer,
386
383
  Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
387
384
  this.settingsUpdate,
388
385
  )
389
386
  this.listenTo(
390
- this.container,
387
+ this.core.activeContainer,
391
388
  Events.CONTAINER_HIGHDEFINITIONUPDATE,
392
389
  this.highDefinitionUpdate,
393
390
  )
394
391
  this.listenTo(
395
- this.container,
392
+ this.core.activeContainer,
396
393
  Events.CONTAINER_MEDIACONTROL_DISABLE,
397
394
  this.disable,
398
395
  )
399
396
  this.listenTo(
400
- this.container,
397
+ this.core.activeContainer,
401
398
  Events.CONTAINER_MEDIACONTROL_ENABLE,
402
399
  this.enable,
403
400
  )
404
- this.listenTo(this.container, Events.CONTAINER_ENDED, this.ended)
405
- this.listenTo(this.container, Events.CONTAINER_VOLUME, this.onVolumeChanged)
401
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_ENDED, this.ended)
402
+ this.listenTo(this.core.activeContainer, Events.CONTAINER_VOLUME, this.onVolumeChanged)
406
403
  this.listenTo(
407
- this.container,
404
+ this.core.activeContainer,
408
405
  Events.CONTAINER_OPTIONS_CHANGE,
409
406
  this.setInitialVolume,
410
407
  )
411
- if (this.container.playback.el.nodeName.toLowerCase() === 'video') {
408
+ if (this.core.activePlayback.el.nodeName.toLowerCase() === 'video') {
412
409
  // wait until the metadata has loaded and then check if fullscreen on video tag is supported
413
410
  this.listenToOnce(
414
- this.container,
411
+ this.core.activeContainer,
415
412
  Events.CONTAINER_LOADEDMETADATA,
416
413
  this.onLoadedMetadataOnVideoTag,
417
414
  )
@@ -455,7 +452,7 @@ export class MediaControl extends UICorePlugin {
455
452
  }
456
453
 
457
454
  private onLoadedMetadataOnVideoTag(event: any) {
458
- const video = this.playback && this.playback.el
455
+ const video = this.core.activePlayback?.el
459
456
 
460
457
  // video.webkitSupportsFullscreen is deprecated but iOS appears to only use this
461
458
  // see https://github.com/clappr/clappr/issues/1127
@@ -729,32 +726,33 @@ export class MediaControl extends UICorePlugin {
729
726
 
730
727
  private onActiveContainerChanged() {
731
728
  this.fullScreenOnVideoTagSupported = null
732
- this.bindEvents()
733
729
  // set the new container to match the volume of the last one
734
730
  this.setInitialVolume()
735
731
  this.changeTogglePlay()
736
732
  this.bindContainerEvents()
737
733
  this.settingsUpdate()
738
- this.container &&
739
- this.container.trigger(
734
+ this.core.activeContainer &&
735
+ this.core.activeContainer.trigger(
740
736
  Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
741
- this.container.isDvrInUse(),
737
+ this.core.activeContainer.isDvrInUse(),
742
738
  )
743
- this.container && this.container.mediaControlDisabled && this.disable()
739
+ this.core.activeContainer && this.core.activeContainer.mediaControlDisabled && this.disable()
744
740
  this.trigger(Events.MEDIACONTROL_CONTAINERCHANGED)
745
741
 
746
- if (this.container.$el) {
747
- this.container.$el.addClass('container-skin-1')
742
+ if (this.core.activeContainer.$el) {
743
+ this.core.activeContainer.$el.addClass('container-skin-1')
748
744
  }
749
745
 
750
746
  if (this.options.cropVideo) {
751
- this.container.$el.addClass('crop-video')
747
+ this.core.activeContainer.$el.addClass('crop-video')
752
748
  }
753
749
 
754
- const spinnerPlugin = this.container.getPlugin('spinner')
750
+ // TODO handle by the spinner itself
751
+ const spinnerPlugin = this.core.activeContainer.getPlugin('spinner')
755
752
 
756
753
  spinnerPlugin?.$el.find('div').addClass('gcore-skin-main-color')
757
754
 
755
+ // TODO handle by the seek_time itself
758
756
  const seekTimePlugin = this.container.getPlugin('seek_time')
759
757
 
760
758
  seekTimePlugin?.$el.addClass('gcore-skin-bg-color')
@@ -964,12 +962,11 @@ export class MediaControl extends UICorePlugin {
964
962
  }
965
963
 
966
964
  private settingsUpdate() {
967
- const newSettings = this.getSettings()
968
- $.extend(true, newSettings, {
965
+ const newSettings = $.extend(true, {
969
966
  left: [],
970
967
  default: [],
971
968
  right: [],
972
- })
969
+ }, this.core.activeContainer?.settings)
973
970
 
974
971
  newSettings.left = orderByOrderPattern(
975
972
  [...newSettings.left, 'clipsText', 'volume'],
@@ -1014,11 +1011,6 @@ export class MediaControl extends UICorePlugin {
1014
1011
  }
1015
1012
  }
1016
1013
 
1017
- private getSettings() {
1018
- // TODO show live and remove duration/position if live
1019
- return $.extend(true, {}, this.container && this.container.settings)
1020
- }
1021
-
1022
1014
  private highDefinitionUpdate(isHD: boolean) {
1023
1015
  this.isHD = isHD
1024
1016
  }
@@ -1102,9 +1094,19 @@ export class MediaControl extends UICorePlugin {
1102
1094
  return this.$playbackRate
1103
1095
  case 'seekBarContainer':
1104
1096
  return this.$seekBarContainer
1097
+ case 'subtitlesSelector':
1098
+ return this.$subtitlesSelector
1105
1099
  }
1106
1100
  }
1107
1101
 
1102
+ /**
1103
+ * Get the right panel area to append custom elements to
1104
+ * @returns ZeptoSelector of the right panel element
1105
+ */
1106
+ getRightPanel() {
1107
+ return this.$el.find('.media-control-right-panel')
1108
+ }
1109
+
1108
1110
  private resetIndicators() {
1109
1111
  assert.ok(
1110
1112
  this.$duration && this.$position,
@@ -1298,7 +1300,7 @@ export class MediaControl extends UICorePlugin {
1298
1300
 
1299
1301
  this.changeTogglePlay()
1300
1302
 
1301
- if (this.container) {
1303
+ if (this.core.activeContainer) {
1302
1304
  this.hideId = setTimeout(() => this.hide(), timeout)
1303
1305
  this.disabled && this.hide()
1304
1306
  }
@@ -11,6 +11,7 @@ import {
11
11
  type PlayerMediaSourceDesc,
12
12
  } from '../../types.js'
13
13
  import { trace } from '@gcorevideo/utils'
14
+ import { SpinnerEvents } from '../spinner-three-bounce/SpinnerThreeBounce.js'
14
15
 
15
16
  import { CLAPPR_VERSION } from '../../build.js'
16
17
 
@@ -96,10 +97,16 @@ export class SourceController extends CorePlugin {
96
97
 
97
98
  private sync: SyncFn = noSync
98
99
 
100
+ /**
101
+ * @internal
102
+ */
99
103
  get name() {
100
104
  return 'source_controller'
101
105
  }
102
106
 
107
+ /**
108
+ * @internal
109
+ */
103
110
  get supportedVersion() {
104
111
  return { min: CLAPPR_VERSION }
105
112
  }
@@ -132,7 +139,7 @@ export class SourceController extends CorePlugin {
132
139
  const spinner = this.core.activeContainer?.getPlugin('spinner')
133
140
  if (spinner) {
134
141
  this.sync = (cb: () => void) => {
135
- spinner.once('spinner:sync', cb)
142
+ spinner.once(SpinnerEvents.SYNC, cb)
136
143
  }
137
144
  } else {
138
145
  this.sync = noSync
@@ -228,6 +235,9 @@ export class SourceController extends CorePlugin {
228
235
  })
229
236
  }
230
237
 
238
+ /**
239
+ * @internal
240
+ */
231
241
  static get version() {
232
242
  return VERSION
233
243
  }
@@ -146,7 +146,7 @@ describe('SourceController', () => {
146
146
  it('should sync with the spinner before reloading the source', async () => {
147
147
  await clock.tickAsync(1000)
148
148
  expect(core.load).not.toHaveBeenCalled()
149
- spinner.emit('spinner:sync')
149
+ spinner.emit('plugins:spinner:sync')
150
150
  expect(core.load).toHaveBeenCalled()
151
151
  })
152
152
  })
@@ -2,7 +2,7 @@
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
4
 
5
- import { Container, Events, UIContainerPlugin, template } from '@clappr/core';
5
+ import { Container, Events as ClapprEvents, UIContainerPlugin, template } from '@clappr/core';
6
6
  import { PlaybackError, PlaybackErrorCode } from '../../playback.types.js';
7
7
  import { trace } from '@gcorevideo/utils';
8
8
 
@@ -13,15 +13,41 @@ import { CLAPPR_VERSION } from '../../build.js';
13
13
 
14
14
  const T = 'plugins.spinner'
15
15
 
16
+ /**
17
+ * Custom events emitted by the plugin
18
+ */
19
+ export enum SpinnerEvents {
20
+ /**
21
+ * Emitted at the end of the spinner animation cycle to facilitate smooth UI updates,
22
+ * e.g. {@link SourceController} listens to this event to reload the source when the spinner is hidden
23
+ */
24
+ SYNC = 'plugins:spinner:sync',
25
+ }
26
+
27
+ /**
28
+ * Shows a pending operation indicator when playback is buffering or in other appropriate cases
29
+ * @beta
30
+ * @remarks
31
+ * The plugin emits
32
+ */
16
33
  export class SpinnerThreeBounce extends UIContainerPlugin {
34
+ /**
35
+ * @internal
36
+ */
17
37
  get name() {
18
38
  return 'spinner';
19
39
  }
20
40
 
41
+ /**
42
+ * @internal
43
+ */
21
44
  get supportedVersion() {
22
45
  return { min: CLAPPR_VERSION };
23
46
  }
24
47
 
48
+ /**
49
+ * @internal
50
+ */
25
51
  override get attributes() {
26
52
  return {
27
53
  'data-spinner':'',
@@ -39,13 +65,13 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
39
65
 
40
66
  constructor(container: Container) {
41
67
  super(container);
42
- this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERING, this.onBuffering);
43
- this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERFULL, this.onBufferFull);
44
- this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay);
45
- this.listenTo(this.container, Events.CONTAINER_STOP, this.onStop);
46
- this.listenTo(this.container, Events.CONTAINER_ENDED, this.onStop);
47
- this.listenTo(this.container, Events.CONTAINER_ERROR, this.onError);
48
- this.listenTo(this.container, Events.CONTAINER_READY, this.render);
68
+ this.listenTo(this.container, ClapprEvents.CONTAINER_STATE_BUFFERING, this.onBuffering);
69
+ this.listenTo(this.container, ClapprEvents.CONTAINER_STATE_BUFFERFULL, this.onBufferFull);
70
+ this.listenTo(this.container, ClapprEvents.CONTAINER_PLAY, this.onPlay);
71
+ this.listenTo(this.container, ClapprEvents.CONTAINER_STOP, this.onStop);
72
+ this.listenTo(this.container, ClapprEvents.CONTAINER_ENDED, this.onStop);
73
+ this.listenTo(this.container, ClapprEvents.CONTAINER_ERROR, this.onError);
74
+ this.listenTo(this.container, ClapprEvents.CONTAINER_READY, this.render);
49
75
  }
50
76
 
51
77
  private onBuffering() {
@@ -90,21 +116,16 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
90
116
  }
91
117
  }
92
118
 
93
- show(immediate = false) {
94
- trace(`${T} show`, {
95
- immediate,
96
- })
97
- if (immediate) {
98
- if (this.showTimeout !== null) {
99
- clearTimeout(this.showTimeout);
100
- this.showTimeout = null;
101
- }
102
- this.$el.show();
103
- } else if (this.showTimeout === null) {
104
- this.showTimeout = setTimeout(() => this.$el.show(), 300);
105
- }
119
+ /**
120
+ * Shows the spinner
121
+ */
122
+ show() {
123
+ this.showTimeout = setTimeout(() => this.$el.show(), 300);
106
124
  }
107
125
 
126
+ /**
127
+ * Hides the spinner
128
+ */
108
129
  hide() {
109
130
  if (this.showTimeout !== null) {
110
131
  clearTimeout(this.showTimeout);
@@ -113,6 +134,9 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
113
134
  this.$el.hide();
114
135
  }
115
136
 
137
+ /**
138
+ * @internal
139
+ */
116
140
  override render() {
117
141
  const showOnStart = this.options.spinner?.showOnStart;
118
142
  trace(`${T} render`, {
@@ -121,7 +145,7 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
121
145
  })
122
146
  this.$el.html(this.template());
123
147
  this.el.firstElementChild?.addEventListener('animationiteration', () => {
124
- this.trigger('spinner:sync')
148
+ this.trigger(SpinnerEvents.SYNC)
125
149
  })
126
150
  this.container.$el.append(this.$el[0]);
127
151
  if (showOnStart || this.container.buffering) {