@gcorevideo/player 2.22.0 → 2.22.2

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 (125) hide show
  1. package/assets/bottom-gear/bottomgear copy.ejs +10 -0
  2. package/assets/bottom-gear/bottomgear.ejs +4 -8
  3. package/assets/bottom-gear/gear-sub-menu.scss +0 -1
  4. package/assets/bottom-gear/gear.scss +0 -1
  5. package/assets/clappr-nerd-stats/button.ejs +3 -3
  6. package/assets/level-selector/button.ejs +2 -4
  7. package/assets/level-selector/list.ejs +14 -10
  8. package/assets/level-selector/style.scss +9 -4
  9. package/assets/media-control/container.scss +1 -1
  10. package/assets/playback-rate/list.ejs +5 -5
  11. package/assets/spinner-three-bounce/spinner.scss +1 -1
  12. package/dist/core.js +1 -2
  13. package/dist/index.css +885 -884
  14. package/dist/index.js +3938 -3779
  15. package/dist/player.d.ts +246 -108
  16. package/dist/plugins/index.css +1230 -1229
  17. package/dist/plugins/index.js +4036 -3878
  18. package/docs/api/player.bottomgear.additem.md +95 -0
  19. package/docs/api/player.bottomgear.md +63 -19
  20. package/docs/api/player.bottomgear.refresh.md +5 -1
  21. package/docs/api/player.clapprnerdstats.md +0 -2
  22. package/docs/api/player.clicktopause.md +1 -1
  23. package/docs/api/player.closedcaptions.md +2 -2
  24. package/docs/api/player.closedcaptionspluginsettings.md +5 -0
  25. package/docs/api/player.errorscreen.md +18 -4
  26. package/docs/api/player.errorscreenpluginsettings.md +1 -4
  27. package/docs/api/player.errorscreensettings.md +15 -0
  28. package/docs/api/{player.mediacontrolevents.md → player.gearevents.md} +7 -7
  29. package/docs/api/player.levelselector.events.md +0 -1
  30. package/docs/api/player.levelselector.md +1 -1
  31. package/docs/api/player.md +33 -36
  32. package/docs/api/{player.bottomgear.setcontent.md → player.mediacontrol.handlecustomarea.md} +5 -9
  33. package/docs/api/player.mediacontrol.md +10 -24
  34. package/docs/api/player.mediacontrol.putelement.md +2 -2
  35. package/docs/api/{player.bottomgear.getelement.md → player.mediacontrol.toggleelement.md} +23 -9
  36. package/docs/api/player.mediacontrolelement.md +1 -1
  37. package/docs/api/player.playbackrate.md +22 -3
  38. package/docs/api/{player.gearoptionsitem.md → player.playbackrateoption.md} +6 -4
  39. package/docs/api/{player.mediacontrol.getcenterpanel.md → player.playbackratesettings.md} +8 -6
  40. package/docs/api/player.sourcecontroller._constructor_.md +49 -0
  41. package/docs/api/player.sourcecontroller.md +70 -7
  42. package/docs/api/player.spinnerevents.md +1 -4
  43. package/docs/api/player.spinnerthreebounce._constructor_.md +0 -3
  44. package/docs/api/player.spinnerthreebounce.hide.md +0 -3
  45. package/docs/api/player.spinnerthreebounce.md +5 -8
  46. package/docs/api/player.spinnerthreebounce.show.md +2 -5
  47. package/lib/internal.types.d.ts +5 -0
  48. package/lib/internal.types.d.ts.map +1 -1
  49. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  50. package/lib/playback/dash-playback/DashPlayback.js +0 -1
  51. package/lib/playback.types.d.ts +0 -5
  52. package/lib/playback.types.d.ts.map +1 -1
  53. package/lib/plugins/bottom-gear/BottomGear.d.ts +93 -20
  54. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  55. package/lib/plugins/bottom-gear/BottomGear.js +145 -37
  56. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +2 -3
  57. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
  58. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +18 -15
  59. package/lib/plugins/click-to-pause/ClickToPause.d.ts +1 -1
  60. package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
  61. package/lib/plugins/click-to-pause/ClickToPause.js +3 -2
  62. package/lib/plugins/dvr-controls/DvrControls.js +1 -1
  63. package/lib/plugins/error-screen/ErrorScreen.d.ts +29 -4
  64. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
  65. package/lib/plugins/error-screen/ErrorScreen.js +17 -2
  66. package/lib/plugins/level-selector/LevelSelector.d.ts +8 -11
  67. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  68. package/lib/plugins/level-selector/LevelSelector.js +66 -102
  69. package/lib/plugins/media-control/MediaControl.d.ts +6 -15
  70. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  71. package/lib/plugins/media-control/MediaControl.js +36 -30
  72. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  73. package/lib/plugins/picture-in-picture/PictureInPicture.js +7 -2
  74. package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -14
  75. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
  76. package/lib/plugins/playback-rate/PlaybackRate.js +101 -83
  77. package/lib/plugins/source-controller/SourceController.d.ts +40 -4
  78. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
  79. package/lib/plugins/source-controller/SourceController.js +41 -4
  80. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +8 -6
  81. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  82. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +10 -6
  83. package/lib/plugins/subtitles/ClosedCaptions.d.ts +7 -7
  84. package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
  85. package/lib/plugins/subtitles/ClosedCaptions.js +3 -3
  86. package/lib/testUtils.d.ts +1 -0
  87. package/lib/testUtils.d.ts.map +1 -1
  88. package/lib/testUtils.js +13 -0
  89. package/package.json +1 -1
  90. package/src/internal.types.ts +6 -0
  91. package/src/playback/dash-playback/DashPlayback.ts +0 -1
  92. package/src/playback.types.ts +0 -5
  93. package/src/plugins/bottom-gear/BottomGear.ts +186 -77
  94. package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +21 -5
  95. package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +5 -12
  96. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +27 -25
  97. package/src/plugins/click-to-pause/ClickToPause.ts +3 -2
  98. package/src/plugins/dvr-controls/DvrControls.ts +1 -1
  99. package/src/plugins/dvr-controls/__tests__/DvrControls.test.ts +1 -1
  100. package/src/plugins/error-screen/ErrorScreen.ts +30 -4
  101. package/src/plugins/level-selector/LevelSelector.ts +80 -120
  102. package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +69 -79
  103. package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +38 -71
  104. package/src/plugins/media-control/MediaControl.ts +50 -36
  105. package/src/plugins/media-control/__tests__/MediaControl.test.ts +4 -4
  106. package/src/plugins/picture-in-picture/PictureInPicture.ts +7 -2
  107. package/src/plugins/playback-rate/PlaybackRate.ts +136 -108
  108. package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +84 -37
  109. package/src/plugins/playback-rate/__tests__/__snapshots__/PlaybackRate.test.ts.snap +55 -6
  110. package/src/plugins/source-controller/SourceController.ts +41 -4
  111. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +10 -6
  112. package/src/plugins/subtitles/ClosedCaptions.ts +9 -10
  113. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -1
  114. package/src/testUtils.ts +14 -0
  115. package/src/typings/vitest.d.ts +1 -0
  116. package/temp/player.api.json +303 -370
  117. package/tsconfig.tsbuildinfo +1 -1
  118. package/docs/api/player.gearitemelement.md +0 -18
  119. package/docs/api/player.mediacontrol.getleftpanel.md +0 -22
  120. package/docs/api/player.mediacontrol.getrightpanel.md +0 -22
  121. package/docs/api/player.subtitlespluginsettings.md +0 -18
  122. package/docs/api/player.texttrackitem.id.md +0 -11
  123. package/docs/api/player.texttrackitem.md +0 -87
  124. package/docs/api/player.texttrackitem.name.md +0 -11
  125. package/docs/api/player.texttrackitem.track.md +0 -11
@@ -27,11 +27,47 @@ function noSync(cb: () => void) {
27
27
  }
28
28
 
29
29
  /**
30
- * `PLUGIN` that is responsible for managing the automatic failover between sources.
31
- * @beta
30
+ * `PLUGIN` that is managing the automatic failover between media sources.
31
+ * @public
32
32
  * @remarks
33
33
  * Have a look at the {@link https://miro.com/app/board/uXjVLiN15tY=/?share_link_id=390327585787 | source failover diagram} for the details
34
- * on how sources ordering and selection works.
34
+ * on how sources ordering and selection works. Below is a simplified diagram:
35
+ *
36
+ * ```markdown
37
+ * sources_list:
38
+ * - a.mpd | +--------------------+
39
+ * - b.m3u8 |--->| init |
40
+ * - ... | |--------------------|
41
+ * | current_source = 0 |
42
+ * +--------------------+
43
+ * |
44
+ * | source = a.mpd
45
+ * | playback = dash.js
46
+ * v
47
+ * +------------------+
48
+ * +-->| load source |
49
+ * | +---------|--------+
50
+ * | v
51
+ * | +------------------+
52
+ * | | play |
53
+ * | +---------|--------+
54
+ * | |
55
+ * | v
56
+ * | +-----------------------+
57
+ * | | on playback_error |
58
+ * | |-----------------------|
59
+ * | | current_source = |
60
+ * | | (current_source + 1) |
61
+ * | | % len sources_list |
62
+ * | | |
63
+ * | | delay 1..3s |
64
+ * | +---------------|-------+
65
+ * | |
66
+ * | source=b.m3u8 |
67
+ * | playback=hls.js |
68
+ * +-------------------+
69
+ *
70
+ * ```
35
71
  *
36
72
  * This plugin does not expose any public methods apart from required by the Clappr plugin interface.
37
73
  * It is supposed to work autonomously.
@@ -81,6 +117,7 @@ export class SourceController extends CorePlugin {
81
117
  * | playback=hls.js |
82
118
  * +-------------------+
83
119
  *
120
+ * As can be seen from the diagram, the plugin will endless try to load the next sources rotating between them in round-robin manner.
84
121
  */
85
122
  private sourcesList: PlayerMediaSourceDesc[] = []
86
123
 
@@ -109,7 +146,7 @@ export class SourceController extends CorePlugin {
109
146
  }
110
147
 
111
148
  /**
112
- * @internal
149
+ * @param core - The Clappr core instance.
113
150
  */
114
151
  constructor(core: ClapprCore) {
115
152
  super(core)
@@ -1,6 +1,8 @@
1
+ // This work is based on the original work of Globo.com
1
2
  // Copyright 2014 Globo.com Player authors. All rights reserved.
2
3
  // Use of this source code is governed by a BSD-style
3
4
  // license that can be found in the LICENSE file.
5
+ // https://github.com/clappr/clappr-plugins/blob/ffaa9d27005fa5a8a7c243ffc47eb5655b84b371/LICENSE
4
6
 
5
7
  import {
6
8
  Container,
@@ -20,21 +22,21 @@ const T = 'plugins.spinner'
20
22
 
21
23
  /**
22
24
  * Custom events emitted by the plugin
23
- * @beta
25
+ * @public
24
26
  */
25
27
  export enum SpinnerEvents {
26
28
  /**
27
29
  * Emitted at the end of the spinner animation cycle to facilitate smooth UI updates,
28
- * e.g. {@link SourceController} listens to this event to reload the source when the spinner is hidden
30
+ * for instance, {@link SourceController} listens to this event to reload the source when the spinner is hidden
29
31
  */
30
32
  SYNC = 'plugins:spinner:sync',
31
33
  }
32
34
 
33
35
  /**
34
- * `PLUGIN` that shows a pending operation indicator when playback is buffering or in a similar state
35
- * @beta
36
+ * `PLUGIN` that shows a pending operation indicator when playback is buffering or in a similar state.
37
+ * @public
36
38
  * @remarks
37
- * Events emitted- {@link SpinnerEvents}
39
+ * Events emitted - {@link SpinnerEvents}
38
40
  * Other plugins can use {@link SpinnerThreeBounce.show | show} and {@link SpinnerThreeBounce.hide | hide} methods to
39
41
  * implement custom pending/progress indication scenarios.
40
42
  */
@@ -129,7 +131,9 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
129
131
  /**
130
132
  * Shows the spinner.
131
133
  *
132
- * When called, the spinner will not hide (due to its built-in logic) until {@link SpinnerThreeBounce.hide} is called
134
+ * The method call prevents spinner's built-in logic from automatically hiding it until {@link SpinnerThreeBounce.hide} is called
135
+ *
136
+ * @param delay - The delay in milliseconds before the spinner is shown.
133
137
  */
134
138
  show(delay = 300) {
135
139
  trace(`${T} show`)
@@ -3,7 +3,7 @@ import { reportError, trace } from '@gcorevideo/utils'
3
3
  import assert from 'assert'
4
4
 
5
5
  import { CLAPPR_VERSION } from '../../build.js'
6
- import type { TextTrackItem } from '../../playback.types.js'
6
+ import type { TextTrackItem } from '../../internal.types.js'
7
7
 
8
8
  import '../../../assets/subtitles/style.scss'
9
9
  import subtitlesOffIcon from '../../../assets/icons/new/subtitles-off.svg'
@@ -20,24 +20,23 @@ const LOCAL_STORAGE_CC_ID = 'gplayer.plugins.cc.selected'
20
20
 
21
21
  const T = 'plugins.cc'
22
22
 
23
+ /**
24
+ * Configuration options for the {@link ClosedCaptions} plugin.
25
+ * @beta
26
+ */
23
27
  export type ClosedCaptionsPluginSettings = {
24
28
  /**
25
- * Initially selected subtitles language
29
+ * Initially selected subtitles language.
26
30
  */
27
31
  language?: string
28
32
  }
29
33
 
30
- /**
31
- * @deprecated Use {@link ClosedCaptionsPluginSettings} instead.
32
- */
33
- export type SubtitlesPluginSettings = ClosedCaptionsPluginSettings;
34
-
35
34
  /**
36
35
  * `PLUGIN` that provides a UI to select the subtitles when available.
37
36
  * @beta
38
37
  *
39
38
  * @remarks
40
- * The plugin is activated when closed captions tracks are provided with the media source.
39
+ * The plugin is activated when closed captions tracks are detected in the media source.
41
40
  * It shows a familiar "CC" button with a dropdown menu to select the subtitles language.
42
41
  *
43
42
  * Depends on:
@@ -54,7 +53,7 @@ export type SubtitlesPluginSettings = ClosedCaptionsPluginSettings;
54
53
  * new Player({
55
54
  * ...
56
55
  * cc: {
57
- * language: 'en',
56
+ * language: 'pt-BR',
58
57
  * },
59
58
  * })
60
59
  * ```
@@ -338,7 +337,7 @@ export class ClosedCaptions extends UICorePlugin {
338
337
  this.resizeFont()
339
338
 
340
339
  this.core.activeContainer.$el.append(this.$line)
341
- mediaControl.putElement('cc', this.el)
340
+ mediaControl.putElement('cc', this.$el)
342
341
 
343
342
  this.updateSelection()
344
343
 
@@ -52,7 +52,7 @@ describe('ClosedCaptions', () => {
52
52
  it('should render', () => {
53
53
  expect(cc.el.innerHTML).toMatchSnapshot()
54
54
  expect(cc.$el.find('[data-cc-button]').length).toEqual(1)
55
- expect(mediaControl.putElement).toHaveBeenCalledWith('cc', cc.el)
55
+ expect(mediaControl.putElement).toHaveBeenCalledWith('cc', cc.$el)
56
56
  })
57
57
  })
58
58
  })
package/src/testUtils.ts CHANGED
@@ -193,3 +193,17 @@ export function createMockMediaControl(core: any) {
193
193
  mediaControl.toggleElement = vi.fn()
194
194
  return mediaControl
195
195
  }
196
+
197
+ export function createMockBottomGear(core: any) {
198
+ const plugin: any = new UICorePlugin(core)
199
+ plugin.getItem = vi.fn()
200
+ plugin.addItem = vi.fn().mockImplementation((name: string, $el: any) => {
201
+ const existing = plugin.$el.find(`[data-${name}]`)
202
+ if (existing.length) {
203
+ return existing
204
+ }
205
+ return $('<li></li>').attr(`data-${name}`, '').append($el).appendTo(plugin.$el)
206
+ })
207
+ plugin.refresh = vi.fn()
208
+ return plugin
209
+ }
@@ -1,6 +1,7 @@
1
1
  import 'vitest'
2
2
 
3
3
  interface CustomMatchers<R = unknown> {
4
+ toMatchPlaybackRateOption: (expected: string) => R
4
5
  toMatchQualityLevelLabel: (expected: string) => R
5
6
  toMatchQualityLevelOption: (expected: string) => R
6
7
  }