@gcorevideo/player 2.22.16 → 2.22.18

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 (104) hide show
  1. package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +76 -78
  2. package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +10 -7
  3. package/dist/core.js +10 -14
  4. package/dist/index.css +1441 -1440
  5. package/dist/index.js +589 -522
  6. package/dist/player.d.ts +216 -159
  7. package/dist/plugins/index.css +1204 -1203
  8. package/dist/plugins/index.js +581 -506
  9. package/docs/api/player.clapprstats.exportmetrics.md +1 -1
  10. package/docs/api/player.clapprstats.md +5 -15
  11. package/docs/api/player.clapprstatssettings.md +13 -0
  12. package/docs/api/player.clips.destroy.md +18 -0
  13. package/docs/api/player.clips.disable.md +18 -0
  14. package/docs/api/player.clips.enable.md +18 -0
  15. package/docs/api/player.clips.md +170 -0
  16. package/docs/api/player.clips.render.md +18 -0
  17. package/docs/api/player.clips.supportedversion.md +16 -0
  18. package/docs/api/player.clips.version.md +14 -0
  19. package/docs/api/player.clipspluginsettings.md +2 -2
  20. package/docs/api/player.clipspluginsettings.text.md +1 -1
  21. package/docs/api/player.md +27 -18
  22. package/docs/api/player.mediacontrol.md +1 -1
  23. package/docs/api/{player.mediacontrol.getelement.md → player.mediacontrol.mount.md} +20 -7
  24. package/docs/api/player.mediacontrolleftelement.md +1 -1
  25. package/docs/api/{player.clapprnerdstats._constructor_.md → player.nerdstats._constructor_.md} +3 -3
  26. package/docs/api/{player.clapprnerdstats.md → player.nerdstats.md} +5 -5
  27. package/docs/api/player.qualitylevel.height.md +1 -1
  28. package/docs/api/player.qualitylevel.level.md +1 -1
  29. package/docs/api/player.qualitylevel.md +4 -4
  30. package/docs/api/player.qualitylevel.width.md +1 -1
  31. package/docs/api/player.timeposition.current.md +1 -1
  32. package/docs/api/player.timeposition.md +2 -2
  33. package/docs/api/player.timeposition.total.md +1 -1
  34. package/docs/api/player.timeprogress.md +6 -4
  35. package/docs/api/player.timevalue.md +1 -1
  36. package/lib/index.plugins.d.ts +2 -1
  37. package/lib/index.plugins.d.ts.map +1 -1
  38. package/lib/index.plugins.js +2 -1
  39. package/lib/playback/dash-playback/DashPlayback.d.ts +0 -1
  40. package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
  41. package/lib/playback/dash-playback/DashPlayback.js +9 -12
  42. package/lib/playback/hls-playback/HlsPlayback.d.ts +1 -1
  43. package/lib/playback/hls-playback/HlsPlayback.d.ts.map +1 -1
  44. package/lib/playback/hls-playback/HlsPlayback.js +0 -1
  45. package/lib/playback.types.d.ts +24 -12
  46. package/lib/playback.types.d.ts.map +1 -1
  47. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +4 -0
  48. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
  49. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +20 -23
  50. package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +86 -0
  51. package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -0
  52. package/lib/plugins/clappr-nerd-stats/NerdStats.js +390 -0
  53. package/lib/plugins/clappr-nerd-stats/formatter.d.ts +5 -0
  54. package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -1
  55. package/lib/plugins/clappr-nerd-stats/formatter.js +56 -24
  56. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +2 -2
  57. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
  58. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +1 -1
  59. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -1
  60. package/lib/plugins/clappr-nerd-stats/types.d.ts +3 -0
  61. package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -1
  62. package/lib/plugins/clappr-nerd-stats/utils.d.ts +7 -0
  63. package/lib/plugins/clappr-nerd-stats/utils.d.ts.map +1 -0
  64. package/lib/plugins/clappr-nerd-stats/utils.js +67 -0
  65. package/lib/plugins/clappr-stats/ClapprStats.d.ts +27 -32
  66. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
  67. package/lib/plugins/clappr-stats/ClapprStats.js +94 -202
  68. package/lib/plugins/clappr-stats/types.d.ts +65 -25
  69. package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
  70. package/lib/plugins/clappr-stats/types.js +37 -2
  71. package/lib/plugins/clappr-stats/utils.d.ts +1 -1
  72. package/lib/plugins/clappr-stats/utils.d.ts.map +1 -1
  73. package/lib/plugins/clappr-stats/utils.js +1 -3
  74. package/lib/plugins/seek-time/SeekTime.d.ts +1 -1
  75. package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -1
  76. package/lib/plugins/seek-time/SeekTime.js +3 -4
  77. package/lib/testUtils.d.ts +2 -1
  78. package/lib/testUtils.d.ts.map +1 -1
  79. package/lib/testUtils.js +3 -2
  80. package/package.json +1 -1
  81. package/src/index.plugins.ts +2 -1
  82. package/src/playback/dash-playback/DashPlayback.ts +10 -15
  83. package/src/playback/hls-playback/HlsPlayback.ts +2 -4
  84. package/src/playback.types.ts +25 -11
  85. package/src/plugins/clappr-nerd-stats/NerdStats.ts +503 -0
  86. package/src/plugins/clappr-nerd-stats/formatter.ts +91 -47
  87. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +2 -2
  88. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +1 -1
  89. package/src/plugins/clappr-nerd-stats/types.ts +43 -3
  90. package/src/plugins/clappr-nerd-stats/utils.ts +75 -0
  91. package/src/plugins/clappr-stats/ClapprStats.ts +242 -306
  92. package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +133 -0
  93. package/src/plugins/clappr-stats/types.ts +93 -47
  94. package/src/plugins/clappr-stats/utils.ts +4 -6
  95. package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +3 -4
  96. package/src/plugins/seek-time/SeekTime.ts +4 -5
  97. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -0
  98. package/src/testUtils.ts +3 -2
  99. package/temp/player.api.json +311 -159
  100. package/tsconfig.tsbuildinfo +1 -1
  101. package/docs/api/player.clapprstats.setupdatemetrics.md +0 -56
  102. package/docs/api/player.clipsplugin.gettext.md +0 -58
  103. package/docs/api/player.clipsplugin.md +0 -59
  104. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +0 -435
@@ -1,56 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [ClapprStats](./player.clapprstats.md) &gt; [setUpdateMetrics](./player.clapprstats.setupdatemetrics.md)
4
-
5
- ## ClapprStats.setUpdateMetrics() method
6
-
7
- > This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
8
- >
9
-
10
- Registers a callback to receive the metrics.
11
-
12
- **Signature:**
13
-
14
- ```typescript
15
- setUpdateMetrics(updateMetricsFn: MetricsUpdateFn): void;
16
- ```
17
-
18
- ## Parameters
19
-
20
- <table><thead><tr><th>
21
-
22
- Parameter
23
-
24
-
25
- </th><th>
26
-
27
- Type
28
-
29
-
30
- </th><th>
31
-
32
- Description
33
-
34
-
35
- </th></tr></thead>
36
- <tbody><tr><td>
37
-
38
- updateMetricsFn
39
-
40
-
41
- </td><td>
42
-
43
- MetricsUpdateFn
44
-
45
-
46
- </td><td>
47
-
48
- The callback to receive the metrics
49
-
50
-
51
- </td></tr>
52
- </tbody></table>
53
- **Returns:**
54
-
55
- void
56
-
@@ -1,58 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [ClipsPlugin](./player.clipsplugin.md) &gt; [getText](./player.clipsplugin.gettext.md)
4
-
5
- ## ClipsPlugin.getText() method
6
-
7
- > This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
8
- >
9
-
10
- Returns the text of the current clip.
11
-
12
- **Signature:**
13
-
14
- ```typescript
15
- getText(time: number): string;
16
- ```
17
-
18
- ## Parameters
19
-
20
- <table><thead><tr><th>
21
-
22
- Parameter
23
-
24
-
25
- </th><th>
26
-
27
- Type
28
-
29
-
30
- </th><th>
31
-
32
- Description
33
-
34
-
35
- </th></tr></thead>
36
- <tbody><tr><td>
37
-
38
- time
39
-
40
-
41
- </td><td>
42
-
43
- number
44
-
45
-
46
- </td><td>
47
-
48
- The current time of the player.
49
-
50
-
51
- </td></tr>
52
- </tbody></table>
53
- **Returns:**
54
-
55
- string
56
-
57
- The text of the current clip.
58
-
@@ -1,59 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@gcorevideo/player](./player.md) &gt; [ClipsPlugin](./player.clipsplugin.md)
4
-
5
- ## ClipsPlugin class
6
-
7
- > This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
8
- >
9
-
10
- `PLUGIN` that shows text over the seekbar to indicate the current clip.
11
-
12
- **Signature:**
13
-
14
- ```typescript
15
- export declare class ClipsPlugin extends UICorePlugin
16
- ```
17
- **Extends:** UICorePlugin
18
-
19
- ## Remarks
20
-
21
- Depends on:
22
-
23
- - [MediaControl](./player.mediacontrol.md)
24
-
25
- Configuration options - [ClipsPluginSettings](./player.clipspluginsettings.md)
26
-
27
- ## Methods
28
-
29
- <table><thead><tr><th>
30
-
31
- Method
32
-
33
-
34
- </th><th>
35
-
36
- Modifiers
37
-
38
-
39
- </th><th>
40
-
41
- Description
42
-
43
-
44
- </th></tr></thead>
45
- <tbody><tr><td>
46
-
47
- [getText(time)](./player.clipsplugin.gettext.md)
48
-
49
-
50
- </td><td>
51
-
52
-
53
- </td><td>
54
-
55
- **_(BETA)_** Returns the text of the current clip.
56
-
57
-
58
- </td></tr>
59
- </tbody></table>
@@ -1,435 +0,0 @@
1
- import { UICorePlugin, Events, template, Core, Container } from '@clappr/core'
2
- import { reportError, trace } from '@gcorevideo/utils'
3
- import Mousetrap from 'mousetrap'
4
-
5
- import { CLAPPR_VERSION } from '../../build.js'
6
- import {
7
- ClapprStatsEvents,
8
- Metrics as BaseMetrics,
9
- } from '../clappr-stats/types.js'
10
- import { newMetrics as newBaseMetrics } from '../clappr-stats/utils.js'
11
- import Formatter from './formatter.js'
12
- import {
13
- clearSpeedTestResults,
14
- configureSpeedTest,
15
- drawSpeedTestResults,
16
- initSpeedTest,
17
- startSpeedtest,
18
- stopSpeedtest,
19
- } from './speedtest/index.js'
20
- import { CustomMetrics } from './speedtest/types.js'
21
- import { ZeptoResult } from '../../types.js'
22
-
23
- import '../../../assets/clappr-nerd-stats/clappr-nerd-stats.scss'
24
- import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs'
25
- import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs'
26
- import statsIcon from '../../../assets/icons/new/stats.svg'
27
- import { BottomGear, GearEvents } from '../bottom-gear/BottomGear.js'
28
- import assert from 'assert'
29
-
30
- const qualityClasses = [
31
- 'speedtest-quality-value-1',
32
- 'speedtest-quality-value-2',
33
- 'speedtest-quality-value-3',
34
- 'speedtest-quality-value-4',
35
- 'speedtest-quality-value-5',
36
- ]
37
-
38
- const getDownloadQuality = (speedValue: number): number => {
39
- if (speedValue < 3) {
40
- return 1
41
- } else if (speedValue < 7) {
42
- return 2
43
- } else if (speedValue < 13) {
44
- return 3
45
- } else if (speedValue < 25) {
46
- return 4
47
- } else {
48
- return 5
49
- }
50
- }
51
-
52
- const getPingQuality = (pingValue: number): number => {
53
- if (pingValue < 20) {
54
- return 5
55
- } else if (pingValue < 50) {
56
- return 4
57
- } else if (pingValue < 100) {
58
- return 3
59
- } else if (pingValue < 150) {
60
- return 2
61
- } else {
62
- return 1
63
- }
64
- }
65
-
66
- const generateQualityHtml = (quality: number): string => {
67
- const html = []
68
- const qualityClassName = qualityClasses[quality - 1]
69
-
70
- for (let i = 0; i < qualityClasses.length; i++) {
71
- if (i < quality) {
72
- html.push(
73
- `<div class="speedtest-quality-content-item ${qualityClassName}"></div>`,
74
- )
75
- } else {
76
- html.push('<div class="speedtest-quality-content-item"></div>')
77
- }
78
- }
79
-
80
- return html.join('')
81
- }
82
-
83
- const drawSummary = (
84
- customMetrics: CustomMetrics,
85
- vodContainer: ZeptoResult,
86
- liveContainer: ZeptoResult,
87
- ) => {
88
- const { connectionSpeed, ping } = customMetrics
89
-
90
- if (!connectionSpeed || !ping) {
91
- return
92
- }
93
- const downloadQuality = getDownloadQuality(connectionSpeed)
94
- const pingQuality = getPingQuality(ping)
95
- const liveQuality = Math.min(downloadQuality, pingQuality)
96
- const vodHtml = generateQualityHtml(downloadQuality)
97
- const liveHtml = generateQualityHtml(liveQuality)
98
-
99
- vodContainer.html(vodHtml)
100
- liveContainer.html(liveHtml)
101
- }
102
-
103
- type IconPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
104
-
105
- type Metrics = BaseMetrics & {
106
- general: {
107
- displayResolution?: string
108
- volume?: number
109
- }
110
- custom: CustomMetrics & {
111
- vodQuality?: string
112
- liveQuality?: string
113
- }
114
- }
115
-
116
- const T = 'plugins.clappr_nerd_stats'
117
-
118
- /**
119
- * `PLUGIN` that displays useful network-related statistics.
120
- * @beta
121
- *
122
- * @remarks
123
- * Depends on:
124
- *
125
- * - {@link BottomGear}
126
- *
127
- * - {@link ClapprStats}
128
- *
129
- * The plugin is rendered as an item in the gear menu.
130
- *
131
- * When clicked, it shows an overlay window with the information about the network speed, latency, etc,
132
- * and recommended quality level.
133
- */
134
- export class ClapprNerdStats extends UICorePlugin {
135
- private container: Container | null = null
136
-
137
- private customMetrics: CustomMetrics = {
138
- connectionSpeed: 0,
139
- ping: 0,
140
- jitter: 0,
141
- }
142
-
143
- private metrics: Metrics = newMetrics()
144
-
145
- private showing = false
146
-
147
- private shortcut: string[]
148
-
149
- private iconPosition: IconPosition
150
-
151
- private static readonly buttonTemplate = template(buttonHtml)
152
-
153
- /**
154
- * @internal
155
- */
156
- get name() {
157
- return 'nerd_stats'
158
- }
159
-
160
- /**
161
- * @internal
162
- */
163
- get supportedVersion() {
164
- return { min: CLAPPR_VERSION }
165
- }
166
-
167
- private static readonly template = template(pluginHtml)
168
-
169
- /**
170
- * @internal
171
- */
172
- override get attributes() {
173
- return {
174
- 'data-clappr-nerd-stats': '',
175
- class: 'clappr-nerd-stats',
176
- }
177
- }
178
-
179
- /**
180
- * @internal
181
- */
182
- override get events() {
183
- return {
184
- 'click [data-show-stats-button]': 'showOrHide',
185
- 'click [data-close-button]': 'hide',
186
- 'click [data-refresh-button]': 'refreshSpeedTest',
187
- }
188
- }
189
-
190
- private get statsBoxElem() {
191
- return '.clappr-nerd-stats[data-clappr-nerd-stats] .stats-box'
192
- }
193
-
194
- private get statsBoxWidthThreshold() {
195
- return 720
196
- }
197
-
198
- private get playerWidth() {
199
- return this.core.$el.width()
200
- }
201
-
202
- private get playerHeight() {
203
- return this.core.$el.height()
204
- }
205
-
206
- constructor(core: Core) {
207
- super(core)
208
- this.shortcut = core.options.clapprNerdStats?.shortcut ?? [
209
- 'command+shift+s',
210
- 'ctrl+shift+s',
211
- ]
212
- this.iconPosition =
213
- core.options.clapprNerdStats?.iconPosition ?? 'bottom-right'
214
- this.customMetrics = {
215
- connectionSpeed: 0,
216
- ping: 0,
217
- jitter: 0,
218
- }
219
- configureSpeedTest(core.options.clapprNerdStats?.speedTestServers ?? [])
220
- }
221
-
222
- /**
223
- * @internal
224
- */
225
- override bindEvents() {
226
- this.listenToOnce(this.core, Events.CORE_READY, this.onCoreReady)
227
- }
228
-
229
- private onCoreReady() {
230
- const bottomGear = this.core.getPlugin('bottom_gear') as BottomGear
231
- assert(bottomGear, 'bottom_gear plugin is required')
232
-
233
- this.listenTo(bottomGear, GearEvents.RENDERED, this.addToBottomGear)
234
-
235
- this.container = this.core.activeContainer
236
- const clapprStats = this.container?.getPlugin('clappr_stats')
237
-
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
- }
260
- }
261
-
262
- private toggle() {
263
- if (this.showing) {
264
- this.hide()
265
- } else {
266
- this.show()
267
- }
268
- }
269
-
270
- private show() {
271
- this.core.$el.find(this.statsBoxElem).show()
272
- this.showing = true
273
-
274
- this.refreshSpeedTest()
275
- initSpeedTest(this.customMetrics)
276
- .then(() => {
277
- startSpeedtest()
278
- })
279
- .catch((e) => {
280
- reportError(e)
281
- this.disable()
282
- })
283
- }
284
-
285
- private hide() {
286
- this.core.$el.find(this.statsBoxElem).hide()
287
- this.showing = false
288
- stopSpeedtest()
289
- }
290
-
291
- private onPlayerResize() {
292
- this.setStatsBoxSize()
293
- }
294
-
295
- private addGeneralMetrics() {
296
- this.metrics.general = {
297
- displayResolution: this.playerWidth + 'x' + this.playerHeight,
298
- volume: this.container?.volume,
299
- }
300
- }
301
-
302
- private addCustomMetrics() {
303
- this.metrics.custom = this.customMetrics
304
- const videoQualityNames = [
305
- 'SD (480p)',
306
- 'HD (720p)',
307
- 'Full HD (1080p)',
308
- '2K (1440p)',
309
- '4K (2160p)',
310
- ]
311
- const { connectionSpeed, ping } = this.customMetrics
312
-
313
- if (!connectionSpeed || !ping) {
314
- const calculatingText = 'Calculating... Please wait.'
315
-
316
- this.metrics.custom.vodQuality = calculatingText
317
- this.metrics.custom.liveQuality = calculatingText
318
-
319
- return
320
- }
321
- const downloadQuality = getDownloadQuality(connectionSpeed)
322
- const pingQuality = getPingQuality(ping)
323
- const liveQuality = Math.min(downloadQuality, pingQuality)
324
-
325
- const prefix = 'Optimal for '
326
-
327
- this.metrics.custom.vodQuality =
328
- prefix + videoQualityNames[downloadQuality - 1]
329
- this.metrics.custom.liveQuality =
330
- prefix + videoQualityNames[liveQuality - 1]
331
- }
332
-
333
- private updateMetrics(metrics: BaseMetrics) {
334
- Object.assign(this.metrics, metrics)
335
- this.addGeneralMetrics()
336
- this.addCustomMetrics()
337
-
338
- const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop()
339
-
340
- this.$el.html(
341
- ClapprNerdStats.template({
342
- metrics: Formatter.format(this.metrics),
343
- iconPosition: this.iconPosition,
344
- }),
345
- )
346
- this.setStatsBoxSize()
347
- drawSpeedTestResults()
348
- drawSummary(
349
- this.metrics?.custom,
350
- this.$el.find('.speedtest-quality-content[data-streaming-type="vod"]'),
351
- this.$el.find('.speedtest-quality-content[data-streaming-type="live"]'),
352
- )
353
-
354
- this.core.$el.find(this.statsBoxElem).scrollTop(scrollTop)
355
-
356
- if (!this.showing) {
357
- this.hide()
358
- }
359
- }
360
-
361
- private setStatsBoxSize() {
362
- if (this.playerWidth >= this.statsBoxWidthThreshold) {
363
- this.$el.find(this.statsBoxElem).addClass('wide')
364
- this.$el.find(this.statsBoxElem).removeClass('narrow')
365
- } else {
366
- this.$el.find(this.statsBoxElem).removeClass('wide')
367
- this.$el.find(this.statsBoxElem).addClass('narrow')
368
- }
369
- }
370
-
371
- /**
372
- * @internal
373
- */
374
- override render() {
375
- trace(`${T} render`)
376
- // TODO append to the container
377
- this.core.$el.append(this.$el[0])
378
- this.hide()
379
-
380
- return this
381
- }
382
-
383
- private addToBottomGear() {
384
- trace(`${T} addToBottomGear`)
385
- const gear = this.core.getPlugin('bottom_gear') as BottomGear
386
- const $button = gear
387
- .addItem('nerd')
388
- .html(
389
- ClapprNerdStats.buttonTemplate({
390
- icon: statsIcon,
391
- i18n: this.core.i18n,
392
- }),
393
- )
394
- .on('click', (e: MouseEvent) => {
395
- e.stopPropagation()
396
- this.toggle()
397
- })
398
- }
399
-
400
- private clearCustomMetrics() {
401
- const clapprStats = this.container?.getPlugin('clappr_stats')
402
-
403
- this.customMetrics.connectionSpeed = 0
404
- this.customMetrics.ping = 0
405
- this.customMetrics.jitter = 0
406
-
407
- if (clapprStats) {
408
- this.updateMetrics(clapprStats.exportMetrics())
409
- }
410
- }
411
-
412
- private refreshSpeedTest() {
413
- stopSpeedtest()
414
- setTimeout(() => {
415
- this.clearCustomMetrics()
416
- clearSpeedTestResults()
417
- drawSpeedTestResults()
418
- }, 200)
419
- setTimeout(() => {
420
- startSpeedtest()
421
- }, 800)
422
- }
423
- }
424
-
425
- function newMetrics(): Metrics {
426
- return {
427
- ...newBaseMetrics(),
428
- general: {},
429
- custom: {
430
- connectionSpeed: 0,
431
- ping: 0,
432
- jitter: 0,
433
- },
434
- }
435
- }