@gcorevideo/player 2.22.17 → 2.22.20

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 (120) hide show
  1. package/assets/audio-selector/track-selector.ejs +3 -3
  2. package/assets/bottom-gear/bottomgear.ejs +3 -3
  3. package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +76 -78
  4. package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +10 -7
  5. package/assets/dvr-controls/dvr_controls.scss +0 -12
  6. package/dist/core.js +5 -7
  7. package/dist/index.css +1245 -1251
  8. package/dist/index.js +425 -261
  9. package/dist/player.d.ts +121 -108
  10. package/dist/plugins/index.css +577 -583
  11. package/dist/plugins/index.js +355 -187
  12. package/docs/api/player.bitratetrackrecord.md +20 -0
  13. package/docs/api/player.clapprstats.exportmetrics.md +2 -2
  14. package/docs/api/player.clapprstats.md +0 -4
  15. package/docs/api/player.clapprstatschronograph.md +115 -0
  16. package/docs/api/player.clapprstatscounter.md +211 -0
  17. package/docs/api/player.clapprstatsevents.md +51 -0
  18. package/docs/api/player.clapprstatsmetrics.md +52 -0
  19. package/docs/api/player.clipspluginsettings.md +1 -1
  20. package/docs/api/player.md +57 -2
  21. package/docs/api/player.nerdstats.md +3 -3
  22. package/docs/api/player.playerconfig.md +1 -1
  23. package/docs/api/player.playerconfig.playbacktype.md +6 -1
  24. package/docs/api/player.timeupdate.md +6 -3
  25. package/lib/playback/dash-playback/DashPlayback.d.ts +0 -1
  26. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  27. package/lib/playback/dash-playback/DashPlayback.js +4 -5
  28. package/lib/playback/hls-playback/HlsPlayback.d.ts +1 -1
  29. package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
  30. package/lib/playback/hls-playback/HlsPlayback.js +0 -1
  31. package/lib/playback.types.d.ts +2 -3
  32. package/lib/playback.types.d.ts.map +1 -1
  33. package/lib/plugins/audio-selector/AudioSelector.d.ts +1 -1
  34. package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
  35. package/lib/plugins/audio-selector/AudioSelector.js +15 -8
  36. package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -1
  37. package/lib/plugins/bottom-gear/BottomGear.js +2 -2
  38. package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +17 -14
  39. package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -1
  40. package/lib/plugins/clappr-nerd-stats/NerdStats.js +175 -124
  41. package/lib/plugins/clappr-nerd-stats/formatter.d.ts +5 -0
  42. package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -1
  43. package/lib/plugins/clappr-nerd-stats/formatter.js +56 -24
  44. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +2 -2
  45. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
  46. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +1 -1
  47. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -1
  48. package/lib/plugins/clappr-nerd-stats/types.d.ts +3 -0
  49. package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -1
  50. package/lib/plugins/clappr-nerd-stats/utils.d.ts +7 -0
  51. package/lib/plugins/clappr-nerd-stats/utils.d.ts.map +1 -0
  52. package/lib/plugins/clappr-nerd-stats/utils.js +67 -0
  53. package/lib/plugins/clappr-stats/ClapprStats.d.ts +5 -2
  54. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
  55. package/lib/plugins/clappr-stats/ClapprStats.js +31 -33
  56. package/lib/plugins/clappr-stats/types.d.ts +21 -22
  57. package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
  58. package/lib/plugins/clappr-stats/types.js +22 -22
  59. package/lib/plugins/clappr-stats/utils.d.ts +2 -2
  60. package/lib/plugins/clappr-stats/utils.d.ts.map +1 -1
  61. package/lib/plugins/clappr-stats/utils.js +0 -1
  62. package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
  63. package/lib/plugins/clips/Clips.d.ts +1 -1
  64. package/lib/plugins/dvr-controls/DvrControls.d.ts +6 -2
  65. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
  66. package/lib/plugins/dvr-controls/DvrControls.js +39 -27
  67. package/lib/plugins/media-control/MediaControl.d.ts +6 -2
  68. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  69. package/lib/plugins/media-control/MediaControl.js +20 -9
  70. package/lib/plugins/picture-in-picture/PictureInPicture.js +1 -1
  71. package/lib/plugins/seek-time/SeekTime.d.ts +1 -1
  72. package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -1
  73. package/lib/plugins/seek-time/SeekTime.js +3 -4
  74. package/lib/plugins/subtitles/ClosedCaptions.js +1 -1
  75. package/lib/plugins/vast-ads/VastAds.js +1 -1
  76. package/lib/plugins/vast-ads/rollmanager.js +1 -1
  77. package/lib/testUtils.d.ts.map +1 -1
  78. package/lib/testUtils.js +7 -4
  79. package/lib/types.d.ts +1 -1
  80. package/package.json +3 -3
  81. package/src/playback/__tests__/HTML5Video.test.ts +2 -2
  82. package/src/playback/dash-playback/DashPlayback.ts +5 -7
  83. package/src/playback/hls-playback/HlsPlayback.ts +2 -4
  84. package/src/playback.types.ts +2 -3
  85. package/src/plugins/audio-selector/AudioSelector.ts +14 -7
  86. package/src/plugins/audio-selector/__tests__/AudioSelector.test.ts +8 -8
  87. package/src/plugins/audio-selector/__tests__/__snapshots__/AudioSelector.test.ts.snap +15 -15
  88. package/src/plugins/bottom-gear/BottomGear.ts +2 -2
  89. package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +8 -5
  90. package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +3 -3
  91. package/src/plugins/clappr-nerd-stats/NerdStats.ts +216 -143
  92. package/src/plugins/clappr-nerd-stats/formatter.ts +91 -47
  93. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +2 -2
  94. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +1 -1
  95. package/src/plugins/clappr-nerd-stats/types.ts +43 -3
  96. package/src/plugins/clappr-nerd-stats/utils.ts +75 -0
  97. package/src/plugins/clappr-stats/ClapprStats.ts +41 -40
  98. package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +12 -12
  99. package/src/plugins/clappr-stats/types.ts +43 -44
  100. package/src/plugins/clappr-stats/utils.ts +4 -5
  101. package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
  102. package/src/plugins/clips/Clips.ts +1 -1
  103. package/src/plugins/clips/__tests__/Clips.test.ts +1 -1
  104. package/src/plugins/clips/__tests__/__snapshots__/Clips.test.ts.snap +1 -1
  105. package/src/plugins/dvr-controls/DvrControls.ts +51 -37
  106. package/src/plugins/dvr-controls/__tests__/DvrControls.test.ts +84 -26
  107. package/src/plugins/dvr-controls/__tests__/__snapshots__/DvrControls.test.ts.snap +0 -12
  108. package/src/plugins/media-control/MediaControl.ts +21 -9
  109. package/src/plugins/media-control/__tests__/MediaControl.test.ts +8 -5
  110. package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +20 -20
  111. package/src/plugins/picture-in-picture/PictureInPicture.ts +1 -1
  112. package/src/plugins/seek-time/SeekTime.ts +4 -5
  113. package/src/plugins/subtitles/ClosedCaptions.ts +1 -1
  114. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -1
  115. package/src/plugins/vast-ads/VastAds.ts +1 -1
  116. package/src/plugins/vast-ads/rollmanager.ts +1 -1
  117. package/src/testUtils.ts +11 -5
  118. package/src/types.ts +1 -1
  119. package/temp/player.api.json +630 -12
  120. package/tsconfig.tsbuildinfo +1 -1
@@ -1,109 +1,153 @@
1
- import humanFormat, { ScaleLike } from 'human-format';
2
- import type { MetricsKind, MetricsType } from './types';
1
+ import humanFormat, { ScaleLike } from 'human-format'
2
+ import type { MetricName, MetricsKind, MetricsType } from './types'
3
3
 
4
4
  const timeScale = new humanFormat.Scale({
5
5
  ms: 1,
6
6
  sec: 1000,
7
7
  min: 60000,
8
- hours: 3600000
9
- });
8
+ hours: 3600000,
9
+ })
10
10
 
11
11
  const percentScale = new humanFormat.Scale({
12
- '%': 1
13
- });
12
+ '%': 1,
13
+ })
14
14
 
15
15
  type FormatParams = {
16
- scale?: ScaleLike;
17
- unit?: 'bps';
18
- decimals?: number;
16
+ scale?: ScaleLike
17
+ unit?: 'bps'
18
+ decimals?: number
19
19
  }
20
20
 
21
- const formattingTemplate: Record<MetricsKind, Partial<Record<MetricsType, FormatParams>>> = {
21
+ const metricTemplates: Partial<Record<MetricName, FormatParams>> = {
22
+ fps: {
23
+ scale: 'SI',
24
+ decimals: 0,
25
+ },
26
+ volume: {
27
+ scale: percentScale,
28
+ },
29
+ }
30
+
31
+ const formattingTemplate: Record<
32
+ MetricsKind,
33
+ Partial<Record<MetricsType, FormatParams>>
34
+ > = {
22
35
  general: {
23
36
  volume: {
24
- scale: percentScale
25
- }
37
+ scale: percentScale,
38
+ },
26
39
  },
27
40
  timers: {
28
41
  startup: {
29
- scale: timeScale
42
+ scale: timeScale,
30
43
  },
31
44
  watch: {
32
- scale: timeScale
45
+ scale: timeScale,
33
46
  },
34
47
  pause: {
35
- scale: timeScale
48
+ scale: timeScale,
36
49
  },
37
50
  buffering: {
38
- scale: timeScale
51
+ scale: timeScale,
39
52
  },
40
53
  session: {
41
- scale: timeScale
54
+ scale: timeScale,
42
55
  },
43
56
  latency: {
44
- scale: timeScale
45
- }
57
+ scale: timeScale,
58
+ },
46
59
  },
47
60
  extra: {
48
61
  buffersize: {
49
- scale: timeScale
62
+ scale: timeScale,
50
63
  },
51
64
  duration: {
52
- scale: timeScale
65
+ scale: timeScale,
53
66
  },
54
67
  currentTime: {
55
- scale: timeScale
68
+ scale: timeScale,
56
69
  },
57
70
  bitrateWeightedMean: {
58
- unit: 'bps'
71
+ unit: 'bps',
59
72
  },
60
73
  bitrateMostUsed: {
61
- unit: 'bps'
74
+ unit: 'bps',
62
75
  },
63
76
  bandwidth: {
64
- unit: 'bps'
77
+ unit: 'bps',
65
78
  },
66
79
  watchedPercentage: {
67
- scale: percentScale
80
+ scale: percentScale,
68
81
  },
69
82
  bufferingPercentage: {
70
- scale: percentScale
71
- }
72
- }
73
- };
83
+ scale: percentScale,
84
+ },
85
+ },
86
+ }
74
87
 
75
- type MetricsValue = number | string;
76
- type Metrics = Partial<Record<MetricsKind, Partial<Record<MetricsType, MetricsValue>>>>;
88
+ type MetricsValue = number | string
89
+ type Metrics = Partial<
90
+ Record<MetricsKind, Partial<Record<MetricsType, MetricsValue>>>
91
+ >
77
92
 
78
93
  export default class Formatter {
79
94
  static format(metrics: Metrics): Metrics {
80
- const formattedMetrics: Metrics = {};
95
+ const formattedMetrics: Metrics = {}
81
96
 
82
97
  Object.entries(metrics).forEach(([type, mm]) => {
83
- const fmt: Partial<Record<MetricsType, MetricsValue>> = {};
84
- formattedMetrics[type as MetricsKind] = fmt;
85
- const typeTemplate = formattingTemplate[type as MetricsKind];
98
+ const fmt: Partial<Record<MetricsType, MetricsValue>> = {}
99
+ formattedMetrics[type as MetricsKind] = fmt
100
+ const typeTemplate = formattingTemplate[type as MetricsKind]
86
101
 
87
102
  Object.entries(mm).forEach(([name, value]) => {
88
- // const value = mm[name];
89
-
90
- if (typeTemplate && typeTemplate[name as MetricsType] && (typeof value === 'number') && !isNaN(value)) {
103
+ if (
104
+ typeTemplate &&
105
+ typeTemplate[name as MetricsType] &&
106
+ typeof value === 'number' &&
107
+ !isNaN(value)
108
+ ) {
91
109
  // @ts-ignore
92
- const templateScale = typeTemplate[name as MetricsType].scale || 'SI';
110
+ const templateScale = typeTemplate[name as MetricsType].scale || 'SI'
93
111
  // @ts-ignore
94
- const templateUnit = typeTemplate[name as MetricsType].unit || '';
112
+ const templateUnit = typeTemplate[name as MetricsType].unit || ''
95
113
 
96
114
  fmt[name as MetricsType] = humanFormat(value, {
97
115
  scale: templateScale,
98
116
  unit: templateUnit,
99
- decimals: 2
100
- });
117
+ decimals: 2,
118
+ })
101
119
  } else {
102
- fmt[name as MetricsType] = value;
120
+ fmt[name as MetricsType] = value
103
121
  }
104
- });
105
- });
122
+ })
123
+ })
124
+
125
+ return formattedMetrics
126
+ }
127
+
128
+ static formatVolume(volume: number): string {
129
+ return humanFormat(volume, metricTemplates.volume)
130
+ }
131
+
132
+ static formatTime(time: number): string {
133
+ return humanFormat(time, {
134
+ scale: timeScale,
135
+ })
136
+ }
137
+
138
+ static formatFps(fps: number): string {
139
+ return humanFormat(fps, metricTemplates.fps)
140
+ }
141
+
142
+ static formatPercentage(percentage: number): string {
143
+ return humanFormat(percentage, {
144
+ scale: percentScale,
145
+ })
146
+ }
106
147
 
107
- return formattedMetrics;
148
+ static formatBitrate(bitrate: number): string {
149
+ return humanFormat(bitrate, {
150
+ unit: 'bps',
151
+ })
108
152
  }
109
153
  }
@@ -1,5 +1,5 @@
1
1
  import { type Server, type TestStatusInfo, Speedtest } from './Speedtest.js';
2
- import { CustomMetrics } from './types.js';
2
+ import { SpeedtestMetrics } from './types.js';
3
3
 
4
4
  const DIGITS_THRESHOLD = 99999;
5
5
  const DEFAULT_DOWNLOAD_SPEED = '0.00';
@@ -59,7 +59,7 @@ export function drawSpeedTestResults() {
59
59
 
60
60
  let inited: Promise<void> | null = null;
61
61
 
62
- export const initSpeedTest = (customMetrics: CustomMetrics): Promise<void> => {
62
+ export const initSpeedTest = (customMetrics: SpeedtestMetrics): Promise<void> => {
63
63
  if (inited !== null) {
64
64
  return inited;
65
65
  }
@@ -1,4 +1,4 @@
1
- export type CustomMetrics = {
1
+ export type SpeedtestMetrics = {
2
2
  ping: number;
3
3
  jitter: number;
4
4
  connectionSpeed: number;
@@ -1,3 +1,43 @@
1
- export type MetricsKind = 'general' | 'timers' | 'extra';
2
- export type MetricsType = 'volume' | 'startup' | 'watch' | 'pause' | 'buffering' | 'session' | 'latency' | 'buffersize' | 'duration' | 'currentTime' | 'bitrateWeightedMean' | 'bitrateMostUsed' | 'bandwidth' | 'watchedPercentage' | 'bufferingPercentage';
3
- export type MetricsValue = number;
1
+ export type MetricsKind = 'general' | 'timers' | 'extra'
2
+ export type MetricType = 'general' | 'timers' | 'extra'
3
+ export type MetricsType =
4
+ | 'volume'
5
+ | 'startup'
6
+ | 'watch'
7
+ | 'pause'
8
+ | 'buffering'
9
+ | 'session'
10
+ | 'latency'
11
+ | 'buffersize'
12
+ | 'duration'
13
+ | 'currentTime'
14
+ | 'bitrateWeightedMean'
15
+ | 'bitrateMostUsed'
16
+ | 'bandwidth'
17
+ | 'watchedPercentage'
18
+ | 'bufferingPercentage'
19
+ export type MetricName =
20
+ | 'volume'
21
+ | 'startup'
22
+ | 'watch'
23
+ | 'pause'
24
+ | 'buffering'
25
+ | 'session'
26
+ | 'latency'
27
+ | 'buffersize'
28
+ | 'duration'
29
+ | 'currentTime'
30
+ | 'bitrateWeightedMean'
31
+ | 'bitrateMostUsed'
32
+ | 'bandwidth'
33
+ | 'watchedPercentage'
34
+ | 'bufferingPercentage'
35
+ | 'fps'
36
+ export type MetricKind =
37
+ | 'volume'
38
+ | 'time'
39
+ | 'precisetime'
40
+ | 'percentage'
41
+ | 'bitrate'
42
+ | 'bandwidth'
43
+ export type MetricsValue = number
@@ -0,0 +1,75 @@
1
+ import { ZeptoResult } from "../../types"
2
+ import { SpeedtestMetrics } from "./speedtest/types"
3
+
4
+ const qualityClasses = [
5
+ 'speedtest-quality-value-1',
6
+ 'speedtest-quality-value-2',
7
+ 'speedtest-quality-value-3',
8
+ 'speedtest-quality-value-4',
9
+ 'speedtest-quality-value-5',
10
+ ]
11
+
12
+ export const getDownloadQuality = (speedValue: number): number => {
13
+ if (speedValue < 3) {
14
+ return 1
15
+ } else if (speedValue < 7) {
16
+ return 2
17
+ } else if (speedValue < 13) {
18
+ return 3
19
+ } else if (speedValue < 25) {
20
+ return 4
21
+ } else {
22
+ return 5
23
+ }
24
+ }
25
+
26
+ export const getPingQuality = (pingValue: number): number => {
27
+ if (pingValue < 20) {
28
+ return 5
29
+ } else if (pingValue < 50) {
30
+ return 4
31
+ } else if (pingValue < 100) {
32
+ return 3
33
+ } else if (pingValue < 150) {
34
+ return 2
35
+ } else {
36
+ return 1
37
+ }
38
+ }
39
+
40
+ export const generateQualityHtml = (quality: number): string => {
41
+ const html = []
42
+ const qualityClassName = qualityClasses[quality - 1]
43
+
44
+ for (let i = 0; i < qualityClasses.length; i++) {
45
+ if (i < quality) {
46
+ html.push(
47
+ `<div class="speedtest-quality-content-item ${qualityClassName}"></div>`,
48
+ )
49
+ } else {
50
+ html.push('<div class="speedtest-quality-content-item"></div>')
51
+ }
52
+ }
53
+
54
+ return html.join('')
55
+ }
56
+
57
+ export const drawSummary = (
58
+ customMetrics: SpeedtestMetrics,
59
+ vodContainer: ZeptoResult,
60
+ liveContainer: ZeptoResult,
61
+ ) => {
62
+ const { connectionSpeed, ping } = customMetrics
63
+
64
+ if (!connectionSpeed || !ping) {
65
+ return
66
+ }
67
+ const downloadQuality = getDownloadQuality(connectionSpeed)
68
+ const pingQuality = getPingQuality(ping)
69
+ const liveQuality = Math.min(downloadQuality, pingQuality)
70
+ const vodHtml = generateQualityHtml(downloadQuality)
71
+ const liveHtml = generateQualityHtml(liveQuality)
72
+
73
+ vodContainer.html(vodHtml)
74
+ liveContainer.html(liveHtml)
75
+ }
@@ -8,8 +8,13 @@ import type {
8
8
 
9
9
  import { CLAPPR_VERSION } from '../../build.js'
10
10
  import { TimerId } from '../../utils/types.js'
11
- import type { Metrics } from './types.js'
12
- import { ClapprStatsEvents, Chronograph, Counter } from './types.js'
11
+ import type { ClapprStatsMetrics } from './types.js'
12
+ import {
13
+ ClapprStatsEvents,
14
+ ClapprStatsChronograph,
15
+ ClapprStatsCounter,
16
+ } from './types.js'
17
+ export * from './types.js'
13
18
  import { newMetrics } from './utils.js'
14
19
 
15
20
  export type ClapprStatsSettings = {
@@ -26,6 +31,8 @@ export type ClapprStatsSettings = {
26
31
  * @remarks
27
32
  * This plugin does not render anything and is supposed to be extended or used together with other plugins that actually render something.
28
33
  *
34
+ * @see {@link NerdStats} - a plugin that visualises the playback metrics
35
+ *
29
36
  * Configuration options - {@link ClapprStatsSettings}
30
37
  *
31
38
  * Events - {@link ClapprStatsEvents}
@@ -35,14 +42,14 @@ export class ClapprStats extends ContainerPlugin {
35
42
 
36
43
  private lastDecodedFramesCount = 0
37
44
 
38
- private metrics: Metrics = newMetrics()
45
+ private metrics: ClapprStatsMetrics = newMetrics()
39
46
 
40
- private timers: Record<Chronograph, number> = {
41
- [Chronograph.Startup]: 0,
42
- [Chronograph.Watch]: 0,
43
- [Chronograph.Pause]: 0,
44
- [Chronograph.Buffering]: 0,
45
- [Chronograph.Session]: 0,
47
+ private timers: Record<ClapprStatsChronograph, number> = {
48
+ [ClapprStatsChronograph.Startup]: 0,
49
+ [ClapprStatsChronograph.Watch]: 0,
50
+ [ClapprStatsChronograph.Pause]: 0,
51
+ [ClapprStatsChronograph.Buffering]: 0,
52
+ [ClapprStatsChronograph.Session]: 0,
46
53
  }
47
54
 
48
55
  private runEach: number
@@ -78,21 +85,15 @@ export class ClapprStats extends ContainerPlugin {
78
85
  : new Date().getTime()
79
86
  }
80
87
 
81
- private inc(counter: Counter) {
88
+ private inc(counter: ClapprStatsCounter) {
82
89
  this.metrics.counters[counter] += 1
83
90
  }
84
91
 
85
- // _timerHasStarted(timer) {
86
- // return this[`_start${timer}`] !== undefined;
87
- // }
88
-
89
- private start(timer: Chronograph) {
90
- // this[`_start${timer}`] = this._now();
92
+ private start(timer: ClapprStatsChronograph) {
91
93
  this.timers[timer] = this.now()
92
94
  }
93
95
 
94
- private stop(timer: Chronograph) {
95
- // this._metrics.timers[timer] += this._now() - this[`_start${timer}`];
96
+ private stop(timer: ClapprStatsChronograph) {
96
97
  this.metrics.chrono[timer] += this.now() - this.timers[timer]
97
98
  }
98
99
 
@@ -131,16 +132,16 @@ export class ClapprStats extends ContainerPlugin {
131
132
  )
132
133
  this.listenTo(this.container, CoreEvents.CONTAINER_SEEK, this.onSeek)
133
134
  this.listenTo(this.container, CoreEvents.CONTAINER_ERROR, () =>
134
- this.inc(Counter.Error),
135
+ this.inc(ClapprStatsCounter.Error),
135
136
  )
136
137
  this.listenTo(this.container, CoreEvents.CONTAINER_FULLSCREEN, () =>
137
- this.inc(Counter.Fullscreen),
138
+ this.inc(ClapprStatsCounter.Fullscreen),
138
139
  )
139
140
  this.listenTo(
140
141
  this.container,
141
142
  CoreEvents.CONTAINER_PLAYBACKDVRSTATECHANGED,
142
143
  (dvrInUse: boolean) => {
143
- dvrInUse && this.inc(Counter.DvrUsage)
144
+ dvrInUse && this.inc(ClapprStatsCounter.DvrUsage)
144
145
  },
145
146
  )
146
147
  this.listenTo(
@@ -186,7 +187,7 @@ export class ClapprStats extends ContainerPlugin {
186
187
 
187
188
  this.metrics.extra.bitratesHistory.push({ start: this.now(), bitrate })
188
189
 
189
- this.inc(Counter.ChangeLevel)
190
+ this.inc(ClapprStatsCounter.ChangeLevel)
190
191
  }
191
192
 
192
193
  private stopReporting() {
@@ -200,8 +201,8 @@ export class ClapprStats extends ContainerPlugin {
200
201
 
201
202
  private startTimers() {
202
203
  this.timerId = setInterval(this.buildReport.bind(this), this.runEach)
203
- this.start(Chronograph.Session)
204
- this.start(Chronograph.Startup)
204
+ this.start(ClapprStatsChronograph.Session)
205
+ this.start(ClapprStatsChronograph.Startup)
205
206
  }
206
207
 
207
208
  private onFirstPlaying() {
@@ -211,8 +212,8 @@ export class ClapprStats extends ContainerPlugin {
211
212
  this.onContainerUpdateWhilePlaying,
212
213
  )
213
214
 
214
- this.start(Chronograph.Watch)
215
- this.stop(Chronograph.Startup)
215
+ this.start(ClapprStatsChronograph.Watch)
216
+ this.stop(ClapprStatsChronograph.Startup)
216
217
  }
217
218
 
218
219
  private playAfterPause() {
@@ -221,18 +222,18 @@ export class ClapprStats extends ContainerPlugin {
221
222
  CoreEvents.CONTAINER_TIMEUPDATE,
222
223
  this.onContainerUpdateWhilePlaying,
223
224
  )
224
- this.stop(Chronograph.Pause)
225
- this.start(Chronograph.Watch)
225
+ this.stop(ClapprStatsChronograph.Pause)
226
+ this.start(ClapprStatsChronograph.Watch)
226
227
  }
227
228
 
228
229
  private onPlay() {
229
- this.inc(Counter.Play)
230
+ this.inc(ClapprStatsCounter.Play)
230
231
  }
231
232
 
232
233
  private onPause() {
233
- this.stop(Chronograph.Watch)
234
- this.start(Chronograph.Pause)
235
- this.inc(Counter.Pause)
234
+ this.stop(ClapprStatsChronograph.Watch)
235
+ this.start(ClapprStatsChronograph.Pause)
236
+ this.inc(ClapprStatsCounter.Pause)
236
237
  this.listenToOnce(
237
238
  this.container,
238
239
  CoreEvents.CONTAINER_PLAY,
@@ -246,7 +247,7 @@ export class ClapprStats extends ContainerPlugin {
246
247
  }
247
248
 
248
249
  private onSeek(e: number) {
249
- this.inc(Counter.Seek)
250
+ this.inc(ClapprStatsCounter.Seek)
250
251
  this.metrics.extra.watchHistory.push([e * 1000, e * 1000])
251
252
  }
252
253
 
@@ -282,14 +283,14 @@ export class ClapprStats extends ContainerPlugin {
282
283
 
283
284
  private onContainerUpdateWhilePlaying() {
284
285
  if (this.container.playback.isPlaying()) {
285
- this.stop(Chronograph.Watch)
286
- this.start(Chronograph.Watch)
286
+ this.stop(ClapprStatsChronograph.Watch)
287
+ this.start(ClapprStatsChronograph.Watch)
287
288
  }
288
289
  }
289
290
 
290
291
  private onBuffering() {
291
- this.inc(Counter.Buffering)
292
- this.start(Chronograph.Buffering)
292
+ this.inc(ClapprStatsCounter.Buffering)
293
+ this.start(ClapprStatsChronograph.Buffering)
293
294
  this.listenToOnce(
294
295
  this.container,
295
296
  CoreEvents.CONTAINER_STATE_BUFFERFULL,
@@ -298,7 +299,7 @@ export class ClapprStats extends ContainerPlugin {
298
299
  }
299
300
 
300
301
  private onBufferfull() {
301
- this.stop(Chronograph.Buffering)
302
+ this.stop(ClapprStatsChronograph.Buffering)
302
303
  this.listenToOnce(
303
304
  this.container,
304
305
  CoreEvents.CONTAINER_STATE_BUFFERING,
@@ -317,8 +318,8 @@ export class ClapprStats extends ContainerPlugin {
317
318
  }
318
319
 
319
320
  private buildReport() {
320
- this.stop(Chronograph.Session)
321
- this.start(Chronograph.Session)
321
+ this.stop(ClapprStatsChronograph.Session)
322
+ this.start(ClapprStatsChronograph.Session)
322
323
 
323
324
  this.metrics.extra.playbackName = this.playbackName
324
325
  this.metrics.extra.playbackType = this.playbackType
@@ -4,7 +4,7 @@ import FakeTimers from '@sinonjs/fake-timers'
4
4
 
5
5
  import { ClapprStats } from '../ClapprStats'
6
6
  import { createMockCore } from '../../../testUtils'
7
- import { Chronograph, ClapprStatsEvents, Counter } from '../types'
7
+ import { ClapprStatsChronograph, ClapprStatsCounter, ClapprStatsEvents } from '../types'
8
8
 
9
9
  describe('ClapprStats', () => {
10
10
  let core: any
@@ -29,7 +29,7 @@ describe('ClapprStats', () => {
29
29
  })
30
30
  it('should measure', () => {
31
31
  const metrics = stats.exportMetrics()
32
- expect(metrics.chrono[Chronograph.Startup]).toBe(155)
32
+ expect(metrics.chrono[ClapprStatsChronograph.Startup]).toBe(155)
33
33
  // expect(metrics.times[Chronograph.Session]).toBe(155)
34
34
  })
35
35
  })
@@ -50,8 +50,8 @@ describe('ClapprStats', () => {
50
50
  })
51
51
  it('should measure cumulative play and pause durations', () => {
52
52
  const metrics = stats.exportMetrics()
53
- expect(metrics.chrono[Chronograph.Watch]).toBe(3850)
54
- expect(metrics.chrono[Chronograph.Pause]).toBe(2900)
53
+ expect(metrics.chrono[ClapprStatsChronograph.Watch]).toBe(3850)
54
+ expect(metrics.chrono[ClapprStatsChronograph.Pause]).toBe(2900)
55
55
  })
56
56
  })
57
57
  describe('buffering', () => {
@@ -71,7 +71,7 @@ describe('ClapprStats', () => {
71
71
  })
72
72
  it('should measure cumulative buffering durations', () => {
73
73
  const metrics = stats.exportMetrics()
74
- expect(metrics.chrono[Chronograph.Buffering]).toBe(200)
74
+ expect(metrics.chrono[ClapprStatsChronograph.Buffering]).toBe(200)
75
75
  })
76
76
  })
77
77
  describe('session', () => {
@@ -88,7 +88,7 @@ describe('ClapprStats', () => {
88
88
  it('should measure', () => {
89
89
  expect(onReport).toHaveBeenCalledWith(expect.objectContaining({
90
90
  chrono: expect.objectContaining({
91
- [Chronograph.Session]: 60200,
91
+ [ClapprStatsChronograph.Session]: 60200,
92
92
  }),
93
93
  }))
94
94
  })
@@ -116,16 +116,16 @@ describe('ClapprStats', () => {
116
116
  it('should measure fps', () => {
117
117
  expect(onReport).toHaveBeenNthCalledWith(1, expect.objectContaining({
118
118
  counters: expect.objectContaining({
119
- [Counter.DecodedFrames]: 126,
120
- [Counter.DroppedFrames]: 3,
121
- [Counter.Fps]: expect.closeTo(25, 0),
119
+ [ClapprStatsCounter.DecodedFrames]: 126,
120
+ [ClapprStatsCounter.DroppedFrames]: 3,
121
+ [ClapprStatsCounter.Fps]: expect.closeTo(25, 0),
122
122
  }),
123
123
  }))
124
124
  expect(onReport).toHaveBeenNthCalledWith(2, expect.objectContaining({
125
125
  counters: expect.objectContaining({
126
- [Counter.DecodedFrames]: 275,
127
- [Counter.DroppedFrames]: 4,
128
- [Counter.Fps]: expect.closeTo(30, 0),
126
+ [ClapprStatsCounter.DecodedFrames]: 275,
127
+ [ClapprStatsCounter.DroppedFrames]: 4,
128
+ [ClapprStatsCounter.Fps]: expect.closeTo(30, 0),
129
129
  }),
130
130
  }))
131
131
  })