@gcorevideo/player 2.20.9 → 2.20.11

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 (227) hide show
  1. package/assets/dvr-controls/dvr_controls.scss +0 -2
  2. package/dist/core.js +5 -5
  3. package/dist/index.css +1212 -1215
  4. package/dist/index.js +74 -71
  5. package/dist/player.d.ts +103 -96
  6. package/dist/plugins/index.css +668 -671
  7. package/dist/plugins/index.js +69 -67
  8. package/docs/api/player.audioselector.md +1 -1
  9. package/docs/api/player.bigmutebutton.md +1 -1
  10. package/docs/api/player.bottomgear.md +1 -1
  11. package/docs/api/player.clapprnerdstats.md +1 -1
  12. package/docs/api/player.clapprstats.md +1 -1
  13. package/docs/api/player.clicktopause.md +1 -1
  14. package/docs/api/player.clipsplugin.md +1 -1
  15. package/docs/api/player.containerpluginconstructor.md +3 -5
  16. package/docs/api/player.containersize.md +0 -3
  17. package/docs/api/player.contextmenu.md +1 -1
  18. package/docs/api/player.corepluginconstructor.md +3 -5
  19. package/docs/api/player.dashsettings.md +0 -3
  20. package/docs/api/player.dvrcontrols.md +2 -35
  21. package/docs/api/player.errorlevel.md +0 -3
  22. package/docs/api/player.errorscreen.md +1 -1
  23. package/docs/api/player.favicon.md +1 -1
  24. package/docs/api/player.googleanalytics.md +1 -1
  25. package/docs/api/player.langtag.md +0 -3
  26. package/docs/api/player.levelselector.md +1 -1
  27. package/docs/api/player.logo.md +1 -1
  28. package/docs/api/player.md +69 -80
  29. package/docs/api/player.mediacontrol.md +2 -2
  30. package/docs/api/player.multicamera.md +1 -1
  31. package/docs/api/player.pictureinpicture.md +1 -1
  32. package/docs/api/player.playbackerror.code.md +0 -3
  33. package/docs/api/player.playbackerror.description.md +0 -3
  34. package/docs/api/player.playbackerror.level.md +0 -3
  35. package/docs/api/player.playbackerror.md +8 -11
  36. package/docs/api/player.playbackerror.message.md +0 -3
  37. package/docs/api/player.playbackerror.origin.md +0 -3
  38. package/docs/api/player.playbackerror.scope.md +0 -3
  39. package/docs/api/player.playbackerror.ui.md +1 -3
  40. package/docs/api/player.playbackerrorcode.md +3 -6
  41. package/docs/api/player.playbackmodule.md +0 -3
  42. package/docs/api/player.playbackrate.md +1 -1
  43. package/docs/api/player.playbacktype.md +1 -4
  44. package/docs/api/player.player._constructor_.md +0 -3
  45. package/docs/api/player.player.attachto.md +0 -3
  46. package/docs/api/player.player.configure.md +0 -3
  47. package/docs/api/player.player.destroy.md +0 -3
  48. package/docs/api/player.player.getcurrenttime.md +0 -3
  49. package/docs/api/player.player.getduration.md +0 -3
  50. package/docs/api/player.player.getvolume.md +0 -3
  51. package/docs/api/player.player.isdvrenabled.md +0 -3
  52. package/docs/api/player.player.isdvrinuse.md +0 -3
  53. package/docs/api/player.player.ismuted.md +0 -3
  54. package/docs/api/player.player.isplaying.md +0 -3
  55. package/docs/api/player.player.md +25 -28
  56. package/docs/api/player.player.mute.md +0 -3
  57. package/docs/api/player.player.off.md +0 -3
  58. package/docs/api/player.player.on.md +0 -3
  59. package/docs/api/player.player.pause.md +0 -3
  60. package/docs/api/player.player.play.md +0 -3
  61. package/docs/api/player.player.registerplugin.md +0 -3
  62. package/docs/api/player.player.resize.md +0 -3
  63. package/docs/api/player.player.seek.md +0 -3
  64. package/docs/api/player.player.setvolume.md +0 -3
  65. package/docs/api/player.player.stop.md +0 -3
  66. package/docs/api/player.player.unmute.md +0 -3
  67. package/docs/api/player.player.unregisterplugin.md +14 -7
  68. package/docs/api/player.playercomponenttype.md +0 -3
  69. package/docs/api/player.playerconfig.autoplay.md +0 -3
  70. package/docs/api/player.playerconfig.dash.md +0 -3
  71. package/docs/api/player.playerconfig.debug.md +0 -3
  72. package/docs/api/player.playerconfig.language.md +0 -3
  73. package/docs/api/player.playerconfig.loop.md +0 -3
  74. package/docs/api/player.playerconfig.md +10 -13
  75. package/docs/api/player.playerconfig.mute.md +0 -3
  76. package/docs/api/player.playerconfig.playbacktype.md +0 -3
  77. package/docs/api/player.playerconfig.prioritytransport.md +0 -3
  78. package/docs/api/player.playerconfig.sources.md +0 -3
  79. package/docs/api/player.playerconfig.strings.md +0 -3
  80. package/docs/api/player.playerdebugsettings.md +0 -3
  81. package/docs/api/player.playerdebugtag.md +0 -3
  82. package/docs/api/player.playerevent.md +11 -14
  83. package/docs/api/player.playereventhandler.md +0 -3
  84. package/docs/api/player.playereventparams.md +0 -3
  85. package/docs/api/player.playermediasource.md +0 -3
  86. package/docs/api/player.playermediasourcedesc.md +2 -5
  87. package/docs/api/player.playermediasourcedesc.mimetype.md +0 -3
  88. package/docs/api/player.playermediasourcedesc.source.md +0 -3
  89. package/docs/api/player.playerplugin.md +0 -4
  90. package/docs/api/player.playerpluginconstructor.md +0 -3
  91. package/docs/api/player.poster.md +1 -1
  92. package/docs/api/player.qualitylevel.bitrate.md +0 -3
  93. package/docs/api/player.qualitylevel.height.md +0 -3
  94. package/docs/api/player.qualitylevel.level.md +0 -3
  95. package/docs/api/player.qualitylevel.md +4 -7
  96. package/docs/api/player.qualitylevel.width.md +0 -3
  97. package/docs/api/player.seektime.md +1 -1
  98. package/docs/api/player.share.md +1 -1
  99. package/docs/api/player.skiptime.md +1 -1
  100. package/docs/api/player.sourcecontroller.md +1 -1
  101. package/docs/api/player.spinnerthreebounce.md +1 -1
  102. package/docs/api/player.subtitles.md +1 -1
  103. package/docs/api/player.telemetry.md +1 -1
  104. package/docs/api/player.thumbnails.md +1 -1
  105. package/docs/api/player.timeposition.current.md +0 -3
  106. package/docs/api/player.timeposition.md +2 -5
  107. package/docs/api/player.timeposition.total.md +0 -3
  108. package/docs/api/player.timevalue.md +0 -3
  109. package/docs/api/player.translationkey.md +0 -3
  110. package/docs/api/player.translationsettings.md +0 -3
  111. package/docs/api/player.transportpreference.md +2 -7
  112. package/docs/api/player.volumefade.md +1 -1
  113. package/lib/Player.d.ts +5 -5
  114. package/lib/Player.js +2 -2
  115. package/lib/index.d.ts +18 -1
  116. package/lib/index.d.ts.map +1 -1
  117. package/lib/index.js +18 -1
  118. package/lib/playback.types.d.ts +8 -7
  119. package/lib/playback.types.d.ts.map +1 -1
  120. package/lib/playback.types.js +1 -1
  121. package/lib/plugins/audio-selector/AudioSelector.d.ts +1 -1
  122. package/lib/plugins/audio-selector/AudioSelector.js +1 -1
  123. package/lib/plugins/big-mute-button/BigMuteButton.d.ts +1 -1
  124. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  125. package/lib/plugins/big-mute-button/BigMuteButton.js +1 -2
  126. package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -1
  127. package/lib/plugins/bottom-gear/BottomGear.js +1 -1
  128. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +1 -1
  129. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +1 -1
  130. package/lib/plugins/clappr-stats/ClapprStats.d.ts +1 -1
  131. package/lib/plugins/clappr-stats/ClapprStats.js +1 -1
  132. package/lib/plugins/click-to-pause/ClickToPause.d.ts +1 -1
  133. package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
  134. package/lib/plugins/clips/Clips.d.ts +1 -1
  135. package/lib/plugins/clips/Clips.js +1 -1
  136. package/lib/plugins/context-menu/ContextMenu.d.ts +1 -1
  137. package/lib/plugins/context-menu/ContextMenu.js +1 -1
  138. package/lib/plugins/dvr-controls/DvrControls.d.ts +6 -4
  139. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
  140. package/lib/plugins/dvr-controls/DvrControls.js +28 -36
  141. package/lib/plugins/error-screen/ErrorScreen.d.ts +1 -18
  142. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
  143. package/lib/plugins/error-screen/ErrorScreen.js +1 -1
  144. package/lib/plugins/favicon/Favicon.d.ts +1 -1
  145. package/lib/plugins/favicon/Favicon.js +1 -1
  146. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +1 -1
  147. package/lib/plugins/google-analytics/GoogleAnalytics.js +1 -1
  148. package/lib/plugins/level-selector/LevelSelector.d.ts +1 -1
  149. package/lib/plugins/level-selector/LevelSelector.js +1 -1
  150. package/lib/plugins/logo/Logo.d.ts +1 -1
  151. package/lib/plugins/logo/Logo.js +1 -1
  152. package/lib/plugins/media-control/MediaControl.d.ts +8 -2
  153. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  154. package/lib/plugins/media-control/MediaControl.js +15 -3
  155. package/lib/plugins/multi-camera/MultiCamera.d.ts +1 -1
  156. package/lib/plugins/multi-camera/MultiCamera.js +1 -1
  157. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +1 -1
  158. package/lib/plugins/picture-in-picture/PictureInPicture.js +1 -1
  159. package/lib/plugins/playback-rate/PlaybackRate.d.ts +1 -1
  160. package/lib/plugins/playback-rate/PlaybackRate.js +1 -1
  161. package/lib/plugins/poster/Poster.d.ts +1 -1
  162. package/lib/plugins/poster/Poster.js +1 -1
  163. package/lib/plugins/seek-time/SeekTime.d.ts +1 -1
  164. package/lib/plugins/seek-time/SeekTime.js +1 -1
  165. package/lib/plugins/share/Share.d.ts +1 -1
  166. package/lib/plugins/share/Share.js +1 -1
  167. package/lib/plugins/skip-time/SkipTime.d.ts +1 -1
  168. package/lib/plugins/skip-time/SkipTime.js +1 -1
  169. package/lib/plugins/source-controller/SourceController.d.ts +1 -1
  170. package/lib/plugins/source-controller/SourceController.js +1 -1
  171. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +1 -1
  172. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +1 -1
  173. package/lib/plugins/subtitles/Subtitles.d.ts +1 -1
  174. package/lib/plugins/subtitles/Subtitles.js +1 -1
  175. package/lib/plugins/telemetry/Telemetry.d.ts +1 -1
  176. package/lib/plugins/telemetry/Telemetry.js +1 -1
  177. package/lib/plugins/thumbnails/Thumbnails.d.ts +1 -1
  178. package/lib/plugins/thumbnails/Thumbnails.js +1 -1
  179. package/lib/plugins/volume-fade/VolumeFade.d.ts +1 -1
  180. package/lib/plugins/volume-fade/VolumeFade.js +1 -1
  181. package/lib/testUtils.d.ts +11 -2
  182. package/lib/testUtils.d.ts.map +1 -1
  183. package/lib/testUtils.js +22 -3
  184. package/lib/types.d.ts +20 -25
  185. package/lib/types.d.ts.map +1 -1
  186. package/lib/types.js +1 -1
  187. package/package.json +1 -1
  188. package/src/Player.ts +5 -5
  189. package/src/index.ts +18 -1
  190. package/src/playback.types.ts +8 -7
  191. package/src/plugins/audio-selector/AudioSelector.ts +1 -1
  192. package/src/plugins/big-mute-button/BigMuteButton.ts +1 -2
  193. package/src/plugins/bottom-gear/BottomGear.ts +1 -1
  194. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +1 -1
  195. package/src/plugins/clappr-stats/ClapprStats.ts +1 -1
  196. package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
  197. package/src/plugins/clips/Clips.ts +1 -1
  198. package/src/plugins/context-menu/ContextMenu.ts +1 -1
  199. package/src/plugins/dvr-controls/DvrControls.ts +33 -45
  200. package/src/plugins/dvr-controls/__tests__/DvrControls.test.ts +91 -0
  201. package/src/plugins/dvr-controls/__tests__/__snapshots__/DvrControls.test.ts.snap +43 -0
  202. package/src/plugins/error-screen/ErrorScreen.ts +3 -21
  203. package/src/plugins/favicon/Favicon.ts +1 -1
  204. package/src/plugins/google-analytics/GoogleAnalytics.ts +1 -1
  205. package/src/plugins/level-selector/LevelSelector.ts +1 -1
  206. package/src/plugins/logo/Logo.ts +1 -1
  207. package/src/plugins/media-control/MediaControl.ts +17 -3
  208. package/src/plugins/multi-camera/MultiCamera.ts +1 -1
  209. package/src/plugins/picture-in-picture/PictureInPicture.ts +1 -1
  210. package/src/plugins/playback-rate/PlaybackRate.ts +1 -1
  211. package/src/plugins/poster/Poster.ts +1 -1
  212. package/src/plugins/seek-time/SeekTime.ts +1 -1
  213. package/src/plugins/share/Share.ts +1 -1
  214. package/src/plugins/skip-time/SkipTime.ts +1 -1
  215. package/src/plugins/source-controller/SourceController.ts +1 -1
  216. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +1 -1
  217. package/src/plugins/subtitles/Subtitles.ts +1 -1
  218. package/src/plugins/telemetry/Telemetry.ts +1 -1
  219. package/src/plugins/thumbnails/Thumbnails.ts +1 -1
  220. package/src/plugins/volume-fade/VolumeFade.ts +1 -1
  221. package/src/testUtils.ts +28 -4
  222. package/src/types.ts +20 -26
  223. package/temp/player.api.json +181 -251
  224. package/tsconfig.tsbuildinfo +1 -1
  225. package/docs/api/player.dvrcontrols._constructor_.md +0 -50
  226. package/docs/api/player.errordesc.md +0 -28
  227. package/docs/api/player.mediatransport.md +0 -16
@@ -0,0 +1,91 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
2
+ import { DvrControls } from '../DvrControls.js'
3
+ import { createMockCore, createMockMediaControl } from '../../../testUtils.js'
4
+ // import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
5
+
6
+ // setTracer(new LogTracer('DvrControls.test'))
7
+ // Logger.enable('*')
8
+
9
+ describe('DvrControls', () => {
10
+ let core: any
11
+ let mediaControl: any
12
+ let plugins: Record<string, any> = {}
13
+ let dvrControls: DvrControls
14
+ beforeEach(() => {
15
+ core = createMockCore()
16
+ mediaControl = createMockMediaControl(core)
17
+ plugins = {
18
+ media_control: mediaControl,
19
+ }
20
+ core.getPlugin.mockImplementation((name: string) => plugins[name])
21
+ dvrControls = new DvrControls(core)
22
+ plugins.dvr_controls = dvrControls
23
+ })
24
+ describe('live stream', () => {
25
+ beforeEach(() => {
26
+ core.getPlaybackType.mockReturnValue('live')
27
+ })
28
+ describe.each([
29
+ ['no DVR', false, false, false],
30
+ ['DVR at live edge', true, false, false],
31
+ ['DVR behind live edge', true, true, true],
32
+ ])('%s', (_, dvrEnabled, dvrInUse, indicateDvr) => {
33
+ beforeEach(() => {
34
+ core.activePlayback.dvrEnabled = dvrEnabled
35
+ core.trigger('core:ready')
36
+ core.trigger('core:active:container:changed')
37
+ if (dvrInUse) {
38
+ core.activeContainer.trigger('container:dvr', true)
39
+ }
40
+ })
41
+ it('should render', () => {
42
+ expect(dvrControls.el.textContent).toBeTruthy()
43
+ expect(dvrControls.el.innerHTML).toMatchSnapshot()
44
+ })
45
+ it('should render to the media control left panel', () => {
46
+ expect(mediaControl.$el.find('.media-control-left-panel').text()).toContain('live')
47
+ expect(mediaControl.el.innerHTML).toMatchSnapshot()
48
+ })
49
+ it('should indicate live streaming mode', () => {
50
+ expect(mediaControl.$el.hasClass('live')).toBe(true)
51
+ })
52
+ if (indicateDvr) {
53
+ it('should indicate DVR mode', () => {
54
+ expect(mediaControl.$el.hasClass('dvr')).toBe(true)
55
+ })
56
+ } else {
57
+ it('should not indicate DVR mode', () => {
58
+ expect(mediaControl.$el.hasClass('dvr')).toBe(false)
59
+ })
60
+ }
61
+ })
62
+ describe('when back_to_live button is clicked', () => {
63
+ beforeEach(() => {
64
+ core.activePlayback.dvrEnabled = true
65
+ core.trigger('core:ready')
66
+ core.trigger('core:active:container:changed')
67
+ core.activeContainer.getDuration.mockReturnValue(180)
68
+ core.activeContainer.trigger('container:dvr', true)
69
+ dvrControls.$el.find('.live-button').click()
70
+ })
71
+ it('should call active container play', () => {
72
+ expect(core.activeContainer.play).toHaveBeenCalled()
73
+ })
74
+ it('should seek to live edge', () => {
75
+ expect(core.activeContainer.seek).toHaveBeenCalledWith(180)
76
+ })
77
+ })
78
+ })
79
+ describe('VOD stream', () => {
80
+ beforeEach(() => {
81
+ core.getPlaybackType.mockReturnValue('vod')
82
+ })
83
+ beforeEach(() => {
84
+ core.trigger('core:ready')
85
+ core.trigger('core:active:container:changed')
86
+ })
87
+ it('should not render', () => {
88
+ expect(dvrControls.el.textContent).toBeFalsy()
89
+ })
90
+ })
91
+ })
@@ -0,0 +1,43 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`DvrControls > live stream > DVR at live edge > should render 1`] = `
4
+ "<div class="live-info">live</div>
5
+ <button type="button" class="live-button" aria-label="back_to_live">back_to_live</button>
6
+ "
7
+ `;
8
+
9
+ exports[`DvrControls > live stream > DVR at live edge > should render to the media control left panel 1`] = `
10
+ "<div class="media-control-left-panel" data-media-control=""><div class="dvr-controls" data-dvr-controls=""><div class="live-info">live</div>
11
+ <button type="button" class="live-button" aria-label="back_to_live">back_to_live</button>
12
+ </div></div>
13
+ <div class="media-control-right-panel" data-media-control=""></div>
14
+ <div class="media-control-center-panel" data-media-control=""></div>"
15
+ `;
16
+
17
+ exports[`DvrControls > live stream > DVR behind live edge > should render 1`] = `
18
+ "<div class="live-info">live</div>
19
+ <button type="button" class="live-button" aria-label="back_to_live">back_to_live</button>
20
+ "
21
+ `;
22
+
23
+ exports[`DvrControls > live stream > DVR behind live edge > should render to the media control left panel 1`] = `
24
+ "<div class="media-control-left-panel" data-media-control=""><div class="dvr-controls" data-dvr-controls=""><div class="live-info">live</div>
25
+ <button type="button" class="live-button" aria-label="back_to_live">back_to_live</button>
26
+ </div></div>
27
+ <div class="media-control-right-panel" data-media-control=""></div>
28
+ <div class="media-control-center-panel" data-media-control=""></div>"
29
+ `;
30
+
31
+ exports[`DvrControls > live stream > no DVR > should render 1`] = `
32
+ "<div class="live-info">live</div>
33
+ <button type="button" class="live-button" aria-label="back_to_live">back_to_live</button>
34
+ "
35
+ `;
36
+
37
+ exports[`DvrControls > live stream > no DVR > should render to the media control left panel 1`] = `
38
+ "<div class="media-control-left-panel" data-media-control=""><div class="dvr-controls" data-dvr-controls=""><div class="live-info">live</div>
39
+ <button type="button" class="live-button" aria-label="back_to_live">back_to_live</button>
40
+ </div></div>
41
+ <div class="media-control-right-panel" data-media-control=""></div>
42
+ <div class="media-control-center-panel" data-media-control=""></div>"
43
+ `;
@@ -6,25 +6,7 @@ import { CLAPPR_VERSION } from '../../build.js'
6
6
  import reloadIcon from '../../../assets/icons/old/reload.svg'
7
7
  import templateHtml from '../../../assets/error-screen/error_screen.ejs'
8
8
  import '../../../assets/error-screen/error_screen.scss'
9
- import { PlaybackErrorCode } from '../../playback.types.js'
10
-
11
- /**
12
- * An error fired in the player and plugins code to be handled in the UI
13
- * @beta
14
- */
15
- export type ErrorDesc = {
16
- description: string
17
- level: string
18
- code: string
19
- origin: string
20
- scope: string
21
- raw?: string
22
- UI?: {
23
- icon?: string
24
- title: string
25
- message: string
26
- }
27
- }
9
+ import { PlaybackError } from '../../playback.types.js'
28
10
 
29
11
  type ErrorScreenDesc = {
30
12
  title: string
@@ -47,7 +29,7 @@ export type ErrorScreenPluginSettings = {
47
29
  const T = 'plugins.error_screen'
48
30
 
49
31
  /**
50
- * PLUGIN that displays errors nicely in the overlay on top of the player.
32
+ * `PLUGIN` that displays errors nicely in the overlay on top of the player.
51
33
  * @beta
52
34
  */
53
35
  export class ErrorScreen extends UICorePlugin {
@@ -142,7 +124,7 @@ export class ErrorScreen extends UICorePlugin {
142
124
  }
143
125
  }
144
126
 
145
- private onError(err: ErrorDesc) {
127
+ private onError(err: PlaybackError) {
146
128
  trace(`${T} onError`, { err })
147
129
  if (err.UI) {
148
130
  if (this.err) {
@@ -13,7 +13,7 @@ const FAVICON_SELECTOR = 'link[rel="shortcut icon"]';
13
13
  // const oldIcon = $(FAVICON_SELECTOR);
14
14
 
15
15
  /**
16
- * The plugin adds custom favicon to the player's tab.
16
+ * `PLUGIN` that adds custom favicon to the player's tab.
17
17
  * @beta
18
18
  */
19
19
  export class Favicon extends CorePlugin {
@@ -11,7 +11,7 @@ declare const _gaq: {
11
11
  };
12
12
 
13
13
  /**
14
- * An example Google Analytics integration plugin
14
+ * `PLUGIN` that integrates with Google Analytics
15
15
  * @beta
16
16
  */
17
17
  export class GoogleAnalytics extends ContainerPlugin {
@@ -40,7 +40,7 @@ export interface LevelSelectorPluginSettings {
40
40
  }
41
41
 
42
42
  /**
43
- * PLUGIN that provides a UI to select the desired quality level of the playback.
43
+ * `PLUGIN` that provides a UI to select the desired quality level of the playback.
44
44
  * @beta
45
45
  *
46
46
  * @remarks
@@ -21,7 +21,7 @@ type LogoOptions = {
21
21
  };
22
22
 
23
23
  /**
24
- * The plugin adds custom logo to the player.
24
+ * `PLUGIN` that adds custom logo to the player.
25
25
  * @beta
26
26
  */
27
27
  export class Logo extends UIContainerPlugin {
@@ -1,6 +1,8 @@
1
+ // This is a derived work from the {@link https://github.com/clappr/clappr-plugins/tree/ffaa9d27005fa5a8a7c243ffc47eb5655b84b371/src/plugins/media_control | Clappr MediaControl plugin}
2
+ // It is redistributed under the terms of the {@link ../../../../../LICENSE | Apache 2.0} license.
1
3
  // Copyright 2014 Globo.com Player authors. All rights reserved.
2
4
  // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
5
+ // license that can be found in the {@link https://github.com/clappr/clappr-plugins/blob/master/LICENSE | LICENSE}.
4
6
 
5
7
  import assert from 'assert'
6
8
  import {
@@ -88,11 +90,11 @@ type DisabledClickable = {
88
90
  }
89
91
 
90
92
  /**
91
- * PLUGIN that provides a foundation for developing custom media controls UI.
93
+ * `PLUGIN` that provides a foundation for developing custom media controls UI.
92
94
  * @beta
93
95
  * @remarks
94
96
  * The methods exposed are to be used by the other plugins that extend the media control UI.
95
- * The plugin registration should be arranged so that MediaControl is initialized before every other plugin that depends on it.
97
+ * The plugin registration should be arranged so that MediaControl is initialized before every other `PLUGIN` that depends on it.
96
98
  * @example
97
99
  * ```ts
98
100
  * Player.registerPlugin(MediaControl) // <--- This must go first
@@ -1132,6 +1134,18 @@ export class MediaControl extends UICorePlugin {
1132
1134
  return this.$el.find('.media-control-right-panel')
1133
1135
  }
1134
1136
 
1137
+ /**
1138
+ * Get the left panel area to append custom elements to
1139
+ * @returns ZeptoSelector of the left panel element
1140
+ */
1141
+ getLeftPanel() {
1142
+ return this.$el.find('.media-control-left-panel')
1143
+ }
1144
+
1145
+ getCenterPanel() {
1146
+ return this.$el.find('.media-control-center-panel')
1147
+ }
1148
+
1135
1149
  private resetIndicators() {
1136
1150
  assert.ok(
1137
1151
  this.$duration && this.$position,
@@ -26,7 +26,7 @@ const VERSION = '0.0.1';
26
26
  const T = 'plugins.multicamera';
27
27
 
28
28
  /**
29
- * PLUGIN that adds support for loading multiple streams and switching between them using the media control UI.
29
+ * `PLUGIN` that adds support for loading multiple streams and switching between them using the media control UI.
30
30
  * @beta
31
31
  */
32
32
  export class MultiCamera extends UICorePlugin {
@@ -12,7 +12,7 @@ const VERSION = '0.0.1';
12
12
  const T = `plugins.pip`;
13
13
 
14
14
  /**
15
- * Enables picture in picture mode.
15
+ * `PLUGIN` that enables picture in picture mode.
16
16
  * @beta
17
17
  * @remarks
18
18
  * Depends on:
@@ -35,7 +35,7 @@ const DEFAULT_PLAYBACK_RATE = '1.0';
35
35
  const T = 'plugins.playback_rate';
36
36
 
37
37
  /**
38
- * PLUGIN that allows changing the playback speed of the video.
38
+ * `PLUGIN` that allows changing the playback speed of the video.
39
39
  * @beta
40
40
  *
41
41
  * @remarks
@@ -24,7 +24,7 @@ import { PlaybackError } from '../../playback.types.js'
24
24
  const T = 'plugins.poster'
25
25
 
26
26
  /**
27
- * Displays a poster image in the background and a big play button on top when playback is stopped
27
+ * `PLUGIN` that displays a poster image in the background and a big play button on top when playback is stopped
28
28
  * @beta
29
29
  * @remarks
30
30
  * When the playback is stopped, media control UI is disabled.
@@ -14,7 +14,7 @@ import { ZeptoResult } from '../../types.js';
14
14
  const { formatTime } = Utils;
15
15
 
16
16
  /**
17
- * The plugin adds a seek time indicator to the media control UI.
17
+ * `PLUGIN` that adds a seek time indicator to the media control UI.
18
18
  * @beta
19
19
  */
20
20
  export class SeekTime extends UICorePlugin {
@@ -10,7 +10,7 @@ import fbIcon from '../../../assets/icons/old/fb.svg';
10
10
  import twIcon from '../../../assets/icons/old/twitter.svg';
11
11
 
12
12
  /**
13
- * PLUGIN that adds a share button to the media control UI.
13
+ * `PLUGIN` that adds a share button to the media control UI.
14
14
  * @beta
15
15
  */
16
16
  export class Share extends UICorePlugin {
@@ -8,7 +8,7 @@ import '../../../assets/skip-time/style.scss';
8
8
  type Position = 'mid' | 'left' | 'right';
9
9
 
10
10
  /**
11
- * PLUGIN that adds skip controls to the media control UI.
11
+ * `PLUGIN` that adds skip controls to the media control UI.
12
12
  * @beta
13
13
  */
14
14
  export class SkipTime extends UICorePluginOriginal {
@@ -27,7 +27,7 @@ function noSync(cb: () => void) {
27
27
  }
28
28
 
29
29
  /**
30
- * This plugin is responsible for managing the automatic failover between sources.
30
+ * `PLUGIN` that is responsible for managing the automatic failover between sources.
31
31
  * @beta
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
@@ -31,7 +31,7 @@ export enum SpinnerEvents {
31
31
  }
32
32
 
33
33
  /**
34
- * PLUGIN that shows a pending operation indicator when playback is buffering or in a similar state
34
+ * `PLUGIN` that shows a pending operation indicator when playback is buffering or in a similar state
35
35
  * @beta
36
36
  * @remarks
37
37
  * Events emitted- {@link SpinnerEvents}
@@ -34,7 +34,7 @@ type TextTrackInfo = {
34
34
  const NO_TRACK = { language: 'off' }
35
35
 
36
36
  /**
37
- * A {@link MediaControl | media control} plugin that provides a UI to select the subtitles when available.
37
+ * `PLUGIN` that provides a UI to select the subtitles when available.
38
38
  * @beta
39
39
  *
40
40
  * @remarks
@@ -103,7 +103,7 @@ export enum TelemetryEvent {
103
103
  }
104
104
 
105
105
  /**
106
- * PLUGIN that 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.
@@ -38,7 +38,7 @@ type Thumb = {
38
38
  const T = 'plugins.thumbnails'
39
39
 
40
40
  /**
41
- * Displays the thumbnails of the video when available.
41
+ * `PLUGIN` that displays the thumbnails of the video when available.
42
42
  * @beta
43
43
  * @example
44
44
  * ```ts
@@ -12,7 +12,7 @@ export enum VolumeFadeEvents {
12
12
  }
13
13
 
14
14
  /**
15
- * Applies fade effect to the player's volume change.
15
+ * `PLUGIN` that applies fade effect to the player's volume change.
16
16
  * @beta
17
17
  */
18
18
  export class VolumeFade extends UICorePlugin {
package/src/testUtils.ts CHANGED
@@ -82,7 +82,10 @@ export class _MockPlayback extends Events {
82
82
  }
83
83
  }
84
84
 
85
- export function createMockCore(options: Record<string, unknown> = {}, container: any = createMockContainer()) {
85
+ export function createMockCore(
86
+ options: Record<string, unknown> = {},
87
+ container: any = createMockContainer(),
88
+ ) {
86
89
  const el = document.createElement('div')
87
90
  const emitter = new Events()
88
91
  return Object.assign(emitter, {
@@ -90,10 +93,14 @@ export function createMockCore(options: Record<string, unknown> = {}, container:
90
93
  $el: $(el),
91
94
  activePlayback: container.playback,
92
95
  activeContainer: container,
96
+ i18n: {
97
+ t: vi.fn().mockImplementation((key: string) => key),
98
+ },
93
99
  options: {
94
100
  ...options,
95
101
  },
96
102
  configure: vi.fn(),
103
+ getPlaybackType: vi.fn(),
97
104
  getPlugin: vi.fn(),
98
105
  load: vi.fn(),
99
106
  trigger: emitter.emit,
@@ -165,20 +172,37 @@ export function createMockPlayback(name = 'mock') {
165
172
 
166
173
  export function createMockContainer(playback: any = createMockPlayback()) {
167
174
  const el = document.createElement('div')
168
- return Object.assign(new Events(), {
169
- $el: $(el),
175
+ const emitter = new Events()
176
+ return Object.assign(emitter, {
170
177
  el,
171
- getPlugin: vi.fn(),
172
178
  playback,
179
+ $el: $(el),
180
+ getDuration: vi.fn().mockReturnValue(0),
181
+ getPlugin: vi.fn(),
182
+ isPlaying: vi.fn().mockReturnValue(false),
183
+ play: vi.fn(),
184
+ seek: vi.fn(),
185
+ trigger: emitter.emit,
173
186
  })
174
187
  }
175
188
 
176
189
  export function createMockMediaControl(core: any) {
177
190
  const mediaControl = new UICorePlugin(core)
191
+ mediaControl.$el.html(
192
+ `<div class="media-control-left-panel" data-media-control></div>
193
+ <div class="media-control-right-panel" data-media-control></div>
194
+ <div class="media-control-center-panel" data-media-control></div>`,
195
+ )
178
196
  const elements = {
179
197
  gear: $(document.createElement('div')),
180
198
  }
181
199
  // @ts-ignore
182
200
  mediaControl.getElement = vi.fn().mockImplementation((name) => elements[name])
201
+ // @ts-ignore
202
+ mediaControl.getLeftPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-left-panel'))
203
+ // @ts-ignore
204
+ mediaControl.getRightPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-right-panel'))
205
+ // @ts-ignore
206
+ mediaControl.getCenterPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-center-panel'))
183
207
  return mediaControl
184
208
  }
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@ import { $, Container, Core } from "@clappr/core";
6
6
  * @remarks
7
7
  * When the MIME type is provided, it helps the player determine the appropriate playback engine.
8
8
  * If omitted, the player will attempt to detect the type from the source URL extension.
9
- * @beta
9
+ * @public
10
10
  */
11
11
  export interface PlayerMediaSourceDesc {
12
12
  /**
@@ -23,42 +23,36 @@ export interface PlayerMediaSourceDesc {
23
23
 
24
24
  /**
25
25
  * A media source to fetch the media data from
26
- * @beta
26
+ * @public
27
27
  */
28
28
  export type PlayerMediaSource = string | PlayerMediaSourceDesc
29
29
 
30
30
  /**
31
31
  * Debug output category selector
32
- * @beta
32
+ * @public
33
33
  */
34
34
  export type PlayerDebugTag = 'all' | 'clappr' | 'dash' | 'hls' | 'none'
35
35
 
36
36
  /**
37
37
  * @remarks `true` is equivalent to `'all'`, `false` is equivalent to `'none'`
38
- * @beta
38
+ * @public
39
39
  */
40
40
  export type PlayerDebugSettings = PlayerDebugTag | boolean
41
41
 
42
42
  /**
43
- * Type of a stream playback
44
- * @beta
43
+ * Type of a stream
44
+ * @public
45
45
  */
46
46
  export type PlaybackType = 'live' | 'vod'
47
47
 
48
48
  /**
49
- * Media delivery protocol
50
- * @beta
49
+ * Preferred streaming media delivery protocol
50
+ * @public
51
51
  */
52
- export type MediaTransport = 'dash' | 'hls'
52
+ export type TransportPreference = 'dash' | 'hls'
53
53
 
54
54
  /**
55
- * Preferred media delivery protocol
56
- * @beta
57
- */
58
- export type TransportPreference = MediaTransport
59
-
60
- /**
61
- * @beta
55
+ * @public
62
56
  * @see {@link https://clappr.github.io/classes/UIContainerPlugin.html},
63
57
  * {@link https://clappr.github.io/classes/ContainerPlugin.html}
64
58
  */
@@ -67,12 +61,12 @@ export type PlayerPlugin = {
67
61
  }
68
62
 
69
63
  /**
70
- * @beta
64
+ * @public
71
65
  */
72
66
  export type PlayerPluginConstructor = CorePluginConstructor | ContainerPluginConstructor
73
67
 
74
68
  /**
75
- * @beta
69
+ * @public
76
70
  */
77
71
  export type CorePluginConstructor = {
78
72
  new (core: Core): PlayerPlugin
@@ -80,7 +74,7 @@ export type CorePluginConstructor = {
80
74
  }
81
75
 
82
76
  /**
83
- * @beta
77
+ * @public
84
78
  */
85
79
  export type ContainerPluginConstructor = {
86
80
  new (container: Container): PlayerPlugin
@@ -126,7 +120,7 @@ export type ContainerPluginConstructor = {
126
120
  * },
127
121
  * }
128
122
  * ```
129
- * @beta
123
+ * @public
130
124
  */
131
125
  export interface PlayerConfig extends Record<string, unknown> {
132
126
  /**
@@ -194,18 +188,18 @@ export interface PlayerConfig extends Record<string, unknown> {
194
188
  /**
195
189
  * An ISO 639-1 language code.
196
190
  * @example `pt`
197
- * @beta
191
+ * @public
198
192
  */
199
193
  export type LangTag = string
200
194
 
201
195
  /**
202
- * @beta
196
+ * @public
203
197
  */
204
198
  export type TranslationKey = string
205
199
 
206
200
  /**
207
201
  * A plain JS object that must conform to the DASH.js settings schema.
208
- * @beta
202
+ * @public
209
203
  * {@link https://cdn.dashjs.org/latest/jsdoc/module-Settings.html | DASH.js settings}
210
204
  */
211
205
  export type DashSettings = Record<string, unknown>
@@ -232,7 +226,7 @@ export type DashSettings = Record<string, unknown>
232
226
  * }
233
227
  * ```
234
228
  *
235
- * @beta
229
+ * @public
236
230
  */
237
231
  export type TranslationSettings = Partial<
238
232
  Record<LangTag, Record<TranslationKey, string>>
@@ -240,7 +234,7 @@ export type TranslationSettings = Partial<
240
234
 
241
235
  /**
242
236
  * Dimensions of the player container DOM element.
243
- * @beta
237
+ * @public
244
238
  */
245
239
  export type ContainerSize = {
246
240
  width: number
@@ -249,7 +243,7 @@ export type ContainerSize = {
249
243
 
250
244
  /**
251
245
  * A top-level event on the player object
252
- * @beta
246
+ * @public
253
247
  */
254
248
  export enum PlayerEvent {
255
249
  /**