@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
@@ -39,10 +39,14 @@ export declare function createMockCore(options?: Record<string, unknown>, contai
39
39
  $el: any;
40
40
  activePlayback: any;
41
41
  activeContainer: any;
42
+ i18n: {
43
+ t: import("vitest").Mock<(...args: any[]) => any>;
44
+ };
42
45
  options: {
43
46
  [x: string]: unknown;
44
47
  };
45
48
  configure: import("vitest").Mock<(...args: any[]) => any>;
49
+ getPlaybackType: import("vitest").Mock<(...args: any[]) => any>;
46
50
  getPlugin: import("vitest").Mock<(...args: any[]) => any>;
47
51
  load: import("vitest").Mock<(...args: any[]) => any>;
48
52
  trigger: <T extends string | symbol>(event: T, ...args: any[]) => boolean;
@@ -86,10 +90,15 @@ export declare function createMockPlayback(name?: string): Events<string | symbo
86
90
  trigger(event: string, ...args: any[]): void;
87
91
  };
88
92
  export declare function createMockContainer(playback?: any): Events<string | symbol, any> & {
89
- $el: any;
90
93
  el: HTMLDivElement;
91
- getPlugin: import("vitest").Mock<(...args: any[]) => any>;
92
94
  playback: any;
95
+ $el: any;
96
+ getDuration: import("vitest").Mock<(...args: any[]) => any>;
97
+ getPlugin: import("vitest").Mock<(...args: any[]) => any>;
98
+ isPlaying: import("vitest").Mock<(...args: any[]) => any>;
99
+ play: import("vitest").Mock<(...args: any[]) => any>;
100
+ seek: import("vitest").Mock<(...args: any[]) => any>;
101
+ trigger: <T extends string | symbol>(event: T, ...args: any[]) => boolean;
93
102
  };
94
103
  export declare function createMockMediaControl(core: any): UICorePlugin;
95
104
  //# sourceMappingURL=testUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,MAAM;IAErC,SAAS,CAAC,OAAO,EAAE,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,GAAG;IAClB,SAAS,CAAC,WAAW,CAAC,EAAE,GAAG;gBAFjB,OAAO,EAAE,GAAG,EACb,IAAI,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,GAAG,YAAA;IAK7B,IAAI,IAAI,WAEP;IAED,OAAO;IAEP,IAAI;IAEJ,KAAK;IAEL,IAAI;IAEJ,OAAO;IAEP,IAAI;IAEJ,cAAc;IAEd,WAAW;IAIX,QAAQ;IAER,OAAO;IAEP,eAAe;IAIf,kBAAkB;IAIlB,cAAc;IAId,qBAAqB;IAIrB,IAAI;IAEJ,MAAM;IAEN,MAAM;IAEN,SAAS;IAET,eAAe;IAIf,WAAW;IAIX,QAAQ;IAIR,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAGtC;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,SAAS,GAAE,GAA2B;;;;;;;;;;;;EAgB3G;AAED,wBAAgB,gBAAgB;;;EAK/B;AAED,wBAAgB,mBAAmB;;;;;;EAKlC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;mBA2C7B,MAAM,WAAW,GAAG,EAAE;EAIxC;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,GAA0B;;;;;EAQvE;AAED,wBAAgB,sBA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/C"}
package/lib/testUtils.js CHANGED
@@ -68,10 +68,14 @@ export function createMockCore(options = {}, container = createMockContainer())
68
68
  $el: $(el),
69
69
  activePlayback: container.playback,
70
70
  activeContainer: container,
71
+ i18n: {
72
+ t: vi.fn().mockImplementation((key) => key),
73
+ },
71
74
  options: {
72
75
  ...options,
73
76
  },
74
77
  configure: vi.fn(),
78
+ getPlaybackType: vi.fn(),
75
79
  getPlugin: vi.fn(),
76
80
  load: vi.fn(),
77
81
  trigger: emitter.emit,
@@ -139,19 +143,34 @@ export function createMockPlayback(name = 'mock') {
139
143
  }
140
144
  export function createMockContainer(playback = createMockPlayback()) {
141
145
  const el = document.createElement('div');
142
- return Object.assign(new Events(), {
143
- $el: $(el),
146
+ const emitter = new Events();
147
+ return Object.assign(emitter, {
144
148
  el,
145
- getPlugin: vi.fn(),
146
149
  playback,
150
+ $el: $(el),
151
+ getDuration: vi.fn().mockReturnValue(0),
152
+ getPlugin: vi.fn(),
153
+ isPlaying: vi.fn().mockReturnValue(false),
154
+ play: vi.fn(),
155
+ seek: vi.fn(),
156
+ trigger: emitter.emit,
147
157
  });
148
158
  }
149
159
  export function createMockMediaControl(core) {
150
160
  const mediaControl = new UICorePlugin(core);
161
+ mediaControl.$el.html(`<div class="media-control-left-panel" data-media-control></div>
162
+ <div class="media-control-right-panel" data-media-control></div>
163
+ <div class="media-control-center-panel" data-media-control></div>`);
151
164
  const elements = {
152
165
  gear: $(document.createElement('div')),
153
166
  };
154
167
  // @ts-ignore
155
168
  mediaControl.getElement = vi.fn().mockImplementation((name) => elements[name]);
169
+ // @ts-ignore
170
+ mediaControl.getLeftPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-left-panel'));
171
+ // @ts-ignore
172
+ mediaControl.getRightPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-right-panel'));
173
+ // @ts-ignore
174
+ mediaControl.getCenterPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-center-panel'));
156
175
  return mediaControl;
157
176
  }
package/lib/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import { $, Container, Core } from "@clappr/core";
5
5
  * @remarks
6
6
  * When the MIME type is provided, it helps the player determine the appropriate playback engine.
7
7
  * If omitted, the player will attempt to detect the type from the source URL extension.
8
- * @beta
8
+ * @public
9
9
  */
10
10
  export interface PlayerMediaSourceDesc {
11
11
  /**
@@ -20,36 +20,31 @@ export interface PlayerMediaSourceDesc {
20
20
  }
21
21
  /**
22
22
  * A media source to fetch the media data from
23
- * @beta
23
+ * @public
24
24
  */
25
25
  export type PlayerMediaSource = string | PlayerMediaSourceDesc;
26
26
  /**
27
27
  * Debug output category selector
28
- * @beta
28
+ * @public
29
29
  */
30
30
  export type PlayerDebugTag = 'all' | 'clappr' | 'dash' | 'hls' | 'none';
31
31
  /**
32
32
  * @remarks `true` is equivalent to `'all'`, `false` is equivalent to `'none'`
33
- * @beta
33
+ * @public
34
34
  */
35
35
  export type PlayerDebugSettings = PlayerDebugTag | boolean;
36
36
  /**
37
- * Type of a stream playback
38
- * @beta
37
+ * Type of a stream
38
+ * @public
39
39
  */
40
40
  export type PlaybackType = 'live' | 'vod';
41
41
  /**
42
- * Media delivery protocol
43
- * @beta
42
+ * Preferred streaming media delivery protocol
43
+ * @public
44
44
  */
45
- export type MediaTransport = 'dash' | 'hls';
45
+ export type TransportPreference = 'dash' | 'hls';
46
46
  /**
47
- * Preferred media delivery protocol
48
- * @beta
49
- */
50
- export type TransportPreference = MediaTransport;
51
- /**
52
- * @beta
47
+ * @public
53
48
  * @see {@link https://clappr.github.io/classes/UIContainerPlugin.html},
54
49
  * {@link https://clappr.github.io/classes/ContainerPlugin.html}
55
50
  */
@@ -57,18 +52,18 @@ export type PlayerPlugin = {
57
52
  name: string;
58
53
  };
59
54
  /**
60
- * @beta
55
+ * @public
61
56
  */
62
57
  export type PlayerPluginConstructor = CorePluginConstructor | ContainerPluginConstructor;
63
58
  /**
64
- * @beta
59
+ * @public
65
60
  */
66
61
  export type CorePluginConstructor = {
67
62
  new (core: Core): PlayerPlugin;
68
63
  type: string;
69
64
  };
70
65
  /**
71
- * @beta
66
+ * @public
72
67
  */
73
68
  export type ContainerPluginConstructor = {
74
69
  new (container: Container): PlayerPlugin;
@@ -113,7 +108,7 @@ export type ContainerPluginConstructor = {
113
108
  * },
114
109
  * }
115
110
  * ```
116
- * @beta
111
+ * @public
117
112
  */
118
113
  export interface PlayerConfig extends Record<string, unknown> {
119
114
  /**
@@ -171,16 +166,16 @@ export interface PlayerConfig extends Record<string, unknown> {
171
166
  /**
172
167
  * An ISO 639-1 language code.
173
168
  * @example `pt`
174
- * @beta
169
+ * @public
175
170
  */
176
171
  export type LangTag = string;
177
172
  /**
178
- * @beta
173
+ * @public
179
174
  */
180
175
  export type TranslationKey = string;
181
176
  /**
182
177
  * A plain JS object that must conform to the DASH.js settings schema.
183
- * @beta
178
+ * @public
184
179
  * {@link https://cdn.dashjs.org/latest/jsdoc/module-Settings.html | DASH.js settings}
185
180
  */
186
181
  export type DashSettings = Record<string, unknown>;
@@ -206,12 +201,12 @@ export type DashSettings = Record<string, unknown>;
206
201
  * }
207
202
  * ```
208
203
  *
209
- * @beta
204
+ * @public
210
205
  */
211
206
  export type TranslationSettings = Partial<Record<LangTag, Record<TranslationKey, string>>>;
212
207
  /**
213
208
  * Dimensions of the player container DOM element.
214
- * @beta
209
+ * @public
215
210
  */
216
211
  export type ContainerSize = {
217
212
  width: number;
@@ -219,7 +214,7 @@ export type ContainerSize = {
219
214
  };
220
215
  /**
221
216
  * A top-level event on the player object
222
- * @beta
217
+ * @public
223
218
  */
224
219
  export declare enum PlayerEvent {
225
220
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QA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IACH,KAAK,UAAU;IACf;;;OAGG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,IAAI,SAAS;IACb;;;OAGG;IACH,UAAU,eAAe;IACzB;;;OAGG;IACH,YAAY,iBAAiB;CAC9B;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
package/lib/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * A top-level event on the player object
3
- * @beta
3
+ * @public
4
4
  */
5
5
  export var PlayerEvent;
6
6
  (function (PlayerEvent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.20.9",
3
+ "version": "2.20.11",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/Player.ts CHANGED
@@ -26,7 +26,7 @@ import { registerPlaybacks } from './playback/index.js'
26
26
  import { PlaybackError, TimePosition } from './playback.types.js'
27
27
 
28
28
  /**
29
- * @beta
29
+ * @public
30
30
  */
31
31
  export type PlayerEventParams<E extends PlayerEvent> =
32
32
  E extends PlayerEvent.Seek
@@ -46,7 +46,7 @@ export type PlayerEventParams<E extends PlayerEvent> =
46
46
  /**
47
47
  * Type of a listener callback function for a player event.
48
48
  * See the description of the event parameters in {@link PlayerEvent}.
49
- * @beta
49
+ * @public
50
50
  */
51
51
  export type PlayerEventHandler<E extends PlayerEvent> = (
52
52
  ...args: PlayerEventParams<E>
@@ -67,15 +67,15 @@ const DEFAULT_OPTIONS: PlayerConfig = {
67
67
 
68
68
  /**
69
69
  * Module to perform the playback.
70
- * @beta
70
+ * @public
71
71
  */
72
72
  export type PlaybackModule = 'dash' | 'hls' | 'html5_video'
73
73
 
74
74
  type PluginOptions = Record<string, unknown>
75
75
 
76
76
  /**
77
- * The main component to use in the application code.
78
- * @beta
77
+ * `MAIN` component to use in the application code.
78
+ * @public
79
79
  * @remarks
80
80
  * The Player object provides very basic API to control playback.
81
81
  * To build a sophisticated UI, use the plugins framework to tap into the Clappr core.
package/src/index.ts CHANGED
@@ -3,9 +3,26 @@
3
3
  *
4
4
  * @remarks
5
5
  * This package provides a video player for the Gcore streaming platform.
6
- * It is built on top of the Clappr library and provides a framework for building custom integrations.
6
+ * It is built on top of the {@link https://github.com/clappr/clappr | Clappr} library and provides a framework for building custom integrations.
7
7
  * Start with {@link Player} for more information.
8
8
  *
9
+ * Various plugins (marked with `PLUGIN` keyword) are available to extend the player with additional features.
10
+ * @example
11
+ * ```ts
12
+ * import { Player, MediaControl, ErrorScreen } from '@gcorevideo/player'
13
+ *
14
+ * Player.registerPlugin(MediaControl)
15
+ * Player.registerPlugin(ErrorScreen)
16
+ *
17
+ * const player = new Player({
18
+ * autoPlay: true,
19
+ * mute: true,
20
+ * sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
21
+ * })
22
+ *
23
+ * player.attachTo(document.getElementById('container'))
24
+ * ```
25
+ *
9
26
  * @packageDocumentation
10
27
  */
11
28
  export * from './index.core.js'
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Playback time in seconds since the beginning of the stream (or a segment for the live streams)
3
- * @beta
3
+ * @public
4
4
  */
5
5
  export type TimeValue = number
6
6
 
7
7
  /**
8
8
  * Current playback time and total duration of the media.
9
- * @beta
9
+ * @public
10
10
  */
11
11
  export interface TimePosition {
12
12
  /**
@@ -35,7 +35,7 @@ export type TimeUpdate = TimePosition & {
35
35
 
36
36
  /**
37
37
  * A level of quality within a media source.
38
- * @beta
38
+ * @public
39
39
  */
40
40
  export interface QualityLevel {
41
41
  /**
@@ -58,7 +58,7 @@ export interface QualityLevel {
58
58
 
59
59
  /**
60
60
  * Codes of errors occurring within the playback component.
61
- * @beta
61
+ * @public
62
62
  */
63
63
  export enum PlaybackErrorCode {
64
64
  /**
@@ -77,19 +77,19 @@ export enum PlaybackErrorCode {
77
77
 
78
78
  /**
79
79
  * Levels of severity of errors. Non-fatal errors usually can be ignored.
80
- * @beta
80
+ * @public
81
81
  */
82
82
  export type ErrorLevel = 'FATAL' | 'WARN' | 'INFO'
83
83
 
84
84
  /**
85
85
  * Subsystems of a player component.
86
- * @beta
86
+ * @public
87
87
  */
88
88
  export type PlayerComponentType = 'container' | 'core' | 'playback'
89
89
 
90
90
  /**
91
91
  * An error occurred during the playback.
92
- * @beta
92
+ * @public
93
93
  */
94
94
  export interface PlaybackError {
95
95
  /**
@@ -127,5 +127,6 @@ export interface PlaybackError {
127
127
  UI?: {
128
128
  title: string
129
129
  message: string
130
+ icon?: string
130
131
  }
131
132
  }
@@ -43,7 +43,7 @@ type AudioTrackList = {
43
43
  }
44
44
 
45
45
  /**
46
- * Adds an audio track selector to the media control UI.
46
+ * `PLUGIN` that adds an audio track selector to the media control UI.
47
47
  * @beta
48
48
  */
49
49
  export class AudioSelector extends UICorePlugin {
@@ -13,7 +13,7 @@ const T = 'plugins.big_mute_button'
13
13
  // TODO rewrite as a container plugin
14
14
 
15
15
  /**
16
- * Displays a big mute button over the video when it's muted.
16
+ * `PLUGIN` that displays a big mute button over the video when it's muted.
17
17
  * Once pressed, it unmutes the video.
18
18
  * @beta
19
19
  */
@@ -56,7 +56,6 @@ export class BigMuteButton extends UICorePlugin {
56
56
  * @internal
57
57
  */
58
58
  override bindEvents() {
59
- super.bindEvents()
60
59
  this.listenTo(this.core, Events.CORE_READY, this.onCoreReady)
61
60
  this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
62
61
  this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
@@ -23,7 +23,7 @@ const T = 'plugins.bottom_gear';
23
23
  export type GearItemElement = 'quality' | 'rate' | 'nerd';
24
24
 
25
25
  /**
26
- * Adds the gear button that triggers extra options menu on the right side of the {@link MediaControl | media control} UI
26
+ * `PLUGIN` that adds the gear button with an extra options menu on the right side of the {@link MediaControl | media control} UI
27
27
  * @beta
28
28
  * @remarks
29
29
  * The plugins provides a base for attaching custom settings UI in the gear menu
@@ -117,7 +117,7 @@ type Metrics = BaseMetrics & {
117
117
  // const T = 'plugins.clappr_nerd_stats';
118
118
 
119
119
  /**
120
- * PLUGIN that displays useful network-related statistics.
120
+ * `PLUGIN` that displays useful network-related statistics.
121
121
  * @beta
122
122
  *
123
123
  * @remarks
@@ -23,7 +23,7 @@ type UriToMeasureBandwidth = {
23
23
  const updateMetrics = () => {};
24
24
 
25
25
  /**
26
- * PLIGIN that collects useful statistics about playback performance.
26
+ * `PLUGIN` that collects useful statistics about playback performance.
27
27
  * @beta
28
28
  * @remarks
29
29
  * This plugin does not render anything and is supposed to be extended or used together with other plugins that actually render something.
@@ -12,7 +12,7 @@ type Timer = ReturnType<typeof setTimeout>
12
12
  const T = 'plugins.click_to_pause_custom'
13
13
 
14
14
  /**
15
- * Adds a behavior of toggling the playback state on click over the container
15
+ * `PLUGIN` that adds a behavior of toggling the playback state on click over the container
16
16
  * @beta
17
17
  */
18
18
  export class ClickToPause extends ContainerPlugin {
@@ -30,7 +30,7 @@ export interface ClipsPluginSettings {
30
30
  }
31
31
 
32
32
  /**
33
- * PLUGIN that shows text over the seekbar to indicate the current clip.
33
+ * `PLUGIN` that shows text over the seekbar to indicate the current clip.
34
34
  * @beta
35
35
  * @remarks
36
36
  * Depends on:
@@ -28,7 +28,7 @@ export interface ContextMenuPluginSettings {
28
28
  }
29
29
 
30
30
  /**
31
- * Displays a small context menu when clicked on the player container.
31
+ * `PLUGIN` that displays a small context menu when clicked on the player container.
32
32
  * @beta
33
33
  * @remarks
34
34
  * Configuration options - {@link ContextMenuPluginSettings}
@@ -6,11 +6,12 @@ import { CLAPPR_VERSION } from '../../build.js'
6
6
  import dvrHTML from '../../../assets/dvr-controls/index.ejs'
7
7
  import '../../../assets/dvr-controls/dvr_controls.scss'
8
8
  import { trace } from '@gcorevideo/utils'
9
+ import { MediaControl } from '../media-control/MediaControl.js'
9
10
 
10
11
  const T = 'plugins.dvr_controls'
11
12
 
12
13
  /**
13
- * PLUGIN that adds the DVR controls to the media control UI
14
+ * `PLUGIN` that adds the DVR controls to the media control UI
14
15
  *
15
16
  * @beta
16
17
  *
@@ -19,7 +20,9 @@ const T = 'plugins.dvr_controls'
19
20
  *
20
21
  * - {@link MediaControl}
21
22
  *
22
- * The plugin renders live stream indicator and the DVR seek bar, if DVR is enabled, in the media control UI.
23
+ * The plugin renders live stream indicator.
24
+ * If DVR is enabled, the indicator shows whether the current position is at the live edge of the stream or not.
25
+ * In the latter case, the indicator can be clicked to seek to the live edge.
23
26
  */
24
27
  export class DvrControls extends UICorePlugin {
25
28
  private static readonly template = template(dvrHTML)
@@ -57,15 +60,20 @@ export class DvrControls extends UICorePlugin {
57
60
  }
58
61
  }
59
62
 
60
- constructor(core: Core) {
61
- super(core)
62
- this.settingsUpdate()
63
- }
64
-
65
63
  /**
66
64
  * @internal
67
65
  */
68
66
  override bindEvents() {
67
+ this.listenTo(this.core, Events.CORE_READY, this.onCoreReady)
68
+ this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.render)
69
+ this.listenTo(
70
+ this.core,
71
+ Events.CORE_ACTIVE_CONTAINER_CHANGED,
72
+ this.bindContainerEvents,
73
+ )
74
+ }
75
+
76
+ private onCoreReady() {
69
77
  const mediaControl = this.core.getPlugin('media_control')
70
78
  assert(mediaControl, 'media_control plugin is required')
71
79
  this.listenTo(
@@ -73,12 +81,7 @@ export class DvrControls extends UICorePlugin {
73
81
  Events.MEDIACONTROL_RENDERED,
74
82
  this.settingsUpdate,
75
83
  )
76
- this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.render)
77
- this.listenTo(
78
- this.core,
79
- Events.CORE_ACTIVE_CONTAINER_CHANGED,
80
- this.bindContainerEvents,
81
- )
84
+ this.settingsUpdate()
82
85
  }
83
86
 
84
87
  private bindContainerEvents() {
@@ -94,57 +97,45 @@ export class DvrControls extends UICorePlugin {
94
97
  )
95
98
  }
96
99
 
97
- private onDvrChanged(dvrEnabled: boolean) {
100
+ private onDvrChanged(dvrInUse: boolean) {
98
101
  trace(`${T} onDvrChanged`, {
99
- dvrEnabled,
102
+ dvrInUse,
100
103
  })
101
104
  if (this.core.getPlaybackType() !== Playback.LIVE) {
102
105
  return
103
106
  }
104
- this.settingsUpdate()
105
- this.core.mediaControl.$el.addClass('live')
106
- if (dvrEnabled) {
107
- // TODO
108
- this.core.mediaControl.$el
107
+ this.render()
108
+ const mediaControl = this.core.getPlugin('media_control')
109
+ mediaControl.$el.addClass('live')
110
+ if (dvrInUse) {
111
+ mediaControl.$el
109
112
  .addClass('dvr')
110
113
  .find(
114
+ // TODO add API, test
111
115
  '.media-control-indicator[data-position], .media-control-indicator[data-duration]',
112
116
  )
113
117
  .hide()
114
118
  } else {
115
- this.core.mediaControl.$el.removeClass('dvr')
119
+ mediaControl.$el.removeClass('dvr')
116
120
  }
117
121
  }
118
122
 
119
123
  private click() {
120
- const mediaControl = this.core.getPlugin('media_control')
121
124
  const container = this.core.activeContainer
122
-
123
125
  if (!container.isPlaying()) {
124
126
  container.play()
125
127
  }
126
-
127
- if (mediaControl.$el.hasClass('dvr')) {
128
- container.seek(container.getDuration())
129
- }
128
+ container.seek(container.getDuration())
130
129
  }
131
130
 
132
131
  private settingsUpdate() {
133
- // @ts-ignore
134
- this.stopListening() // TODO sort out
135
- this.core.getPlugin('media_control').$el.removeClass('live') // TODO don't access directly
136
- if (this.shouldRender()) {
137
- this.render()
138
- this.$el.click(() => this.click())
139
- }
140
- this.bindEvents()
132
+ trace(`${T} settingsUpdate`)
133
+ this.core.getPlugin('media_control').$el.removeClass('live')
134
+ this.render()
141
135
  }
142
136
 
143
137
  private shouldRender() {
144
- const useDvrControls =
145
- this.core.options.useDvrControls === undefined ||
146
- !!this.core.options.useDvrControls
147
-
138
+ const useDvrControls = this.core.options.useDvrControls !== false
148
139
  return useDvrControls && this.core.getPlaybackType() === Playback.LIVE
149
140
  }
150
141
 
@@ -154,6 +145,7 @@ export class DvrControls extends UICorePlugin {
154
145
  override render() {
155
146
  trace(`${T} render`, {
156
147
  dvrEnabled: this.core.activePlayback?.dvrEnabled,
148
+ playbackType: this.core.getPlaybackType(),
157
149
  })
158
150
  if (!this.shouldRender()) {
159
151
  return this
@@ -164,13 +156,9 @@ export class DvrControls extends UICorePlugin {
164
156
  backToLive: this.core.i18n.t('back_to_live'),
165
157
  }),
166
158
  )
167
- const mediaControl = this.core.getPlugin('media_control')
168
- assert(mediaControl, 'media_control plugin is required')
169
- // TODO don't tap into the $el directly
159
+ const mediaControl = this.core.getPlugin('media_control') as MediaControl
170
160
  mediaControl.$el.addClass('live')
171
- mediaControl
172
- .$('.media-control-left-panel[data-media-control]')
173
- .append(this.$el)
161
+ mediaControl.getLeftPanel().append(this.$el)
174
162
 
175
163
  return this
176
164
  }