@gcorevideo/player 2.22.16 → 2.22.17

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 (74) hide show
  1. package/dist/core.js +6 -8
  2. package/dist/index.css +1338 -1338
  3. package/dist/index.js +361 -439
  4. package/dist/player.d.ts +216 -159
  5. package/dist/plugins/index.css +1463 -1463
  6. package/dist/plugins/index.js +354 -427
  7. package/docs/api/player.clapprstats.exportmetrics.md +1 -1
  8. package/docs/api/player.clapprstats.md +5 -15
  9. package/docs/api/player.clapprstatssettings.md +13 -0
  10. package/docs/api/player.clips.destroy.md +18 -0
  11. package/docs/api/player.clips.disable.md +18 -0
  12. package/docs/api/player.clips.enable.md +18 -0
  13. package/docs/api/player.clips.md +170 -0
  14. package/docs/api/player.clips.render.md +18 -0
  15. package/docs/api/player.clips.supportedversion.md +16 -0
  16. package/docs/api/player.clips.version.md +14 -0
  17. package/docs/api/player.clipspluginsettings.md +2 -2
  18. package/docs/api/player.clipspluginsettings.text.md +1 -1
  19. package/docs/api/player.md +27 -18
  20. package/docs/api/player.mediacontrol.md +1 -1
  21. package/docs/api/{player.mediacontrol.getelement.md → player.mediacontrol.mount.md} +20 -7
  22. package/docs/api/player.mediacontrolleftelement.md +1 -1
  23. package/docs/api/{player.clapprnerdstats._constructor_.md → player.nerdstats._constructor_.md} +3 -3
  24. package/docs/api/{player.clapprnerdstats.md → player.nerdstats.md} +5 -5
  25. package/docs/api/player.qualitylevel.height.md +1 -1
  26. package/docs/api/player.qualitylevel.level.md +1 -1
  27. package/docs/api/player.qualitylevel.md +4 -4
  28. package/docs/api/player.qualitylevel.width.md +1 -1
  29. package/docs/api/player.timeposition.current.md +1 -1
  30. package/docs/api/player.timeposition.md +2 -2
  31. package/docs/api/player.timeposition.total.md +1 -1
  32. package/docs/api/player.timeprogress.md +6 -4
  33. package/docs/api/player.timevalue.md +1 -1
  34. package/lib/index.plugins.d.ts +2 -1
  35. package/lib/index.plugins.d.ts.map +1 -1
  36. package/lib/index.plugins.js +2 -1
  37. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  38. package/lib/playback/dash-playback/DashPlayback.js +5 -7
  39. package/lib/playback.types.d.ts +22 -9
  40. package/lib/playback.types.d.ts.map +1 -1
  41. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +4 -0
  42. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
  43. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +20 -23
  44. package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +83 -0
  45. package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -0
  46. package/lib/plugins/clappr-nerd-stats/NerdStats.js +339 -0
  47. package/lib/plugins/clappr-stats/ClapprStats.d.ts +27 -32
  48. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
  49. package/lib/plugins/clappr-stats/ClapprStats.js +94 -202
  50. package/lib/plugins/clappr-stats/types.d.ts +65 -24
  51. package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
  52. package/lib/plugins/clappr-stats/types.js +37 -2
  53. package/lib/plugins/clappr-stats/utils.d.ts.map +1 -1
  54. package/lib/plugins/clappr-stats/utils.js +1 -2
  55. package/lib/testUtils.d.ts +2 -1
  56. package/lib/testUtils.d.ts.map +1 -1
  57. package/lib/testUtils.js +3 -2
  58. package/package.json +1 -1
  59. package/src/index.plugins.ts +2 -1
  60. package/src/playback/dash-playback/DashPlayback.ts +5 -8
  61. package/src/playback.types.ts +23 -8
  62. package/src/plugins/clappr-nerd-stats/{ClapprNerdStats.ts → NerdStats.ts} +25 -30
  63. package/src/plugins/clappr-stats/ClapprStats.ts +242 -306
  64. package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +133 -0
  65. package/src/plugins/clappr-stats/types.ts +72 -25
  66. package/src/plugins/clappr-stats/utils.ts +1 -2
  67. package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +3 -4
  68. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -0
  69. package/src/testUtils.ts +3 -2
  70. package/temp/player.api.json +311 -159
  71. package/tsconfig.tsbuildinfo +1 -1
  72. package/docs/api/player.clapprstats.setupdatemetrics.md +0 -56
  73. package/docs/api/player.clipsplugin.gettext.md +0 -58
  74. package/docs/api/player.clipsplugin.md +0 -59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.22.16",
3
+ "version": "2.22.17",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -4,8 +4,9 @@ export * from "./plugins/audio-selector/AudioSelector.js";
4
4
  export { AudioTracks as AudioSelector } from "./plugins/audio-selector/AudioSelector.js";
5
5
  export * from "./plugins/big-mute-button/BigMuteButton.js";
6
6
  export * from "./plugins/bottom-gear/BottomGear.js";
7
- export * from "./plugins/clappr-nerd-stats/ClapprNerdStats.js";
8
7
  export * from "./plugins/clappr-stats/ClapprStats.js";
8
+ export * from "./plugins/clappr-nerd-stats/NerdStats.js";
9
+ export { NerdStats as ClapprNerdStats } from "./plugins/clappr-nerd-stats/NerdStats.js";
9
10
  export * from "./plugins/click-to-pause/ClickToPause.js";
10
11
  export * from "./plugins/clips/Clips.js";
11
12
  export * from "./plugins/context-menu/ContextMenu.js";
@@ -543,15 +543,12 @@ export default class DashPlayback extends BasePlayback {
543
543
  }
544
544
 
545
545
  override _onProgress() {
546
- if (!this._dash) {
547
- return
548
- }
549
-
550
- let buffer = this._dash.getDashMetrics().getCurrentBufferLevel('video')
546
+ const buffer =
547
+ // @ts-expect-error
548
+ this._dash.getDashMetrics().getCurrentBufferLevel('video') ||
549
+ // @ts-expect-error
550
+ this._dash.getDashMetrics().getCurrentBufferLevel('audio')
551
551
 
552
- if (!buffer) {
553
- buffer = this._dash.getDashMetrics().getCurrentBufferLevel('audio')
554
- }
555
552
  const progress = {
556
553
  start: this.getCurrentTime(),
557
554
  current: this.getCurrentTime() + buffer,
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Playback time in seconds since the beginning of the stream (or a segment for the live streams)
2
+ * Playback time position in seconds since the beginning of the stream.
3
+ * For the live streams this is limited to the length of a segment. When DVR is enabled, this refers to the
3
4
  * @public
4
5
  */
5
6
  export type TimeValue = number
@@ -10,20 +11,33 @@ export type TimeValue = number
10
11
  */
11
12
  export interface TimePosition {
12
13
  /**
13
- * Current playback time, 0..duration, seconds.
14
+ * Current playback time, 0..duration
14
15
  */
15
16
  current: TimeValue
16
17
  /**
17
- * Total duration of the media, seconds.
18
+ * Total duration of the media content (or DVR window size or segment duration for live streams)
18
19
  */
19
20
  total: TimeValue
20
21
  }
21
22
 
22
23
  /**
23
- * For the plugin development
24
+ * Time progress information indicated by Clappr CONTAINER_PROGRESS and PLAYBACK_PROGRESS events.
24
25
  * @beta
25
26
  */
26
- export type TimeProgress = TimePosition & { start: number }
27
+ export type TimeProgress = {
28
+ /**
29
+ * Current playback time
30
+ */
31
+ start: TimeValue
32
+ /**
33
+ * Current buffer length beginning from the start (=current) time
34
+ */
35
+ current: TimeValue
36
+ /**
37
+ * Total duration of the media content
38
+ */
39
+ total: TimeValue
40
+ }
27
41
 
28
42
  /**
29
43
  * For the plugin development
@@ -34,20 +48,21 @@ export type TimeUpdate = TimePosition & {
34
48
  }
35
49
 
36
50
  /**
37
- * A level of quality within a media source.
51
+ * A level of quality within a media source/representation.
38
52
  * @public
39
53
  */
40
54
  export interface QualityLevel {
41
55
  /**
42
56
  * Zero-based index of the quality level.
57
+ * Quality levels go from low to high
43
58
  */
44
59
  level: number
45
60
  /**
46
- * Width of the video, pixels.
61
+ * Width of the video frame, pixels.
47
62
  */
48
63
  width: number
49
64
  /**
50
- * Height of the video, pixels.
65
+ * Height of the video frame, pixels.
51
66
  */
52
67
  height: number
53
68
  /**
@@ -1,6 +1,7 @@
1
1
  import { UICorePlugin, Events, template, Core, Container } from '@clappr/core'
2
2
  import { reportError, trace } from '@gcorevideo/utils'
3
3
  import Mousetrap from 'mousetrap'
4
+ import assert from 'assert'
4
5
 
5
6
  import { CLAPPR_VERSION } from '../../build.js'
6
7
  import {
@@ -25,7 +26,6 @@ import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs'
25
26
  import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs'
26
27
  import statsIcon from '../../../assets/icons/new/stats.svg'
27
28
  import { BottomGear, GearEvents } from '../bottom-gear/BottomGear.js'
28
- import assert from 'assert'
29
29
 
30
30
  const qualityClasses = [
31
31
  'speedtest-quality-value-1',
@@ -113,7 +113,7 @@ type Metrics = BaseMetrics & {
113
113
  }
114
114
  }
115
115
 
116
- const T = 'plugins.clappr_nerd_stats'
116
+ const T = 'plugins.nerd_stats'
117
117
 
118
118
  /**
119
119
  * `PLUGIN` that displays useful network-related statistics.
@@ -131,7 +131,7 @@ const T = 'plugins.clappr_nerd_stats'
131
131
  * When clicked, it shows an overlay window with the information about the network speed, latency, etc,
132
132
  * and recommended quality level.
133
133
  */
134
- export class ClapprNerdStats extends UICorePlugin {
134
+ export class NerdStats extends UICorePlugin {
135
135
  private container: Container | null = null
136
136
 
137
137
  private customMetrics: CustomMetrics = {
@@ -234,32 +234,27 @@ export class ClapprNerdStats extends UICorePlugin {
234
234
 
235
235
  this.container = this.core.activeContainer
236
236
  const clapprStats = this.container?.getPlugin('clappr_stats')
237
+ assert(
238
+ clapprStats,
239
+ 'clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
240
+ 'For more info, visit: https://github.com/clappr/clappr-stats.',
241
+ )
242
+ Mousetrap.bind(this.shortcut, this.toggle)
243
+ this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize)
244
+ this.listenTo(clapprStats, ClapprStatsEvents.REPORT, this.updateMetrics)
245
+ this.updateMetrics(clapprStats.exportMetrics())
246
+ this.render()
247
+ }
237
248
 
238
- if (!clapprStats) {
239
- reportError({
240
- message: 'clappr_stats plugin is not available',
241
- })
242
- console.error(
243
- 'clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
244
- 'For more info, visit: https://github.com/clappr/clappr-stats.',
245
- )
246
- this.disable()
247
- } else {
248
- Mousetrap.bind(this.shortcut, () => this.toggle())
249
- this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize)
250
- // TODO: fix
251
- this.listenTo(
252
- clapprStats,
253
- ClapprStatsEvents.REPORT_EVENT,
254
- this.updateMetrics,
255
- )
256
- clapprStats.setUpdateMetrics(this.updateMetrics.bind(this))
257
- this.updateMetrics(clapprStats.exportMetrics())
258
- this.render()
259
- }
249
+ /**
250
+ * @internal
251
+ */
252
+ override destroy() {
253
+ Mousetrap.unbind(this.shortcut)
254
+ return super.destroy()
260
255
  }
261
256
 
262
- private toggle() {
257
+ private toggle = () => {
263
258
  if (this.showing) {
264
259
  this.hide()
265
260
  } else {
@@ -338,7 +333,7 @@ export class ClapprNerdStats extends UICorePlugin {
338
333
  const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop()
339
334
 
340
335
  this.$el.html(
341
- ClapprNerdStats.template({
336
+ NerdStats.template({
342
337
  metrics: Formatter.format(this.metrics),
343
338
  iconPosition: this.iconPosition,
344
339
  }),
@@ -383,10 +378,10 @@ export class ClapprNerdStats extends UICorePlugin {
383
378
  private addToBottomGear() {
384
379
  trace(`${T} addToBottomGear`)
385
380
  const gear = this.core.getPlugin('bottom_gear') as BottomGear
386
- const $button = gear
387
- .addItem('nerd')
381
+ gear
382
+ .addItem('nerd_stats')
388
383
  .html(
389
- ClapprNerdStats.buttonTemplate({
384
+ NerdStats.buttonTemplate({
390
385
  icon: statsIcon,
391
386
  i18n: this.core.i18n,
392
387
  }),