@gcorevideo/player 2.22.15 → 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.
- package/assets/clips/clips.ejs +1 -0
- package/assets/clips/clips.scss +23 -3
- package/assets/level-selector/list.ejs +9 -3
- package/assets/media-control/media-control.ejs +1 -9
- package/assets/media-control/media-control.scss +0 -25
- package/assets/media-control/width370.scss +4 -4
- package/dist/core.js +6 -8
- package/dist/index.css +855 -855
- package/dist/index.js +609 -664
- package/dist/player.d.ts +426 -302
- package/dist/plugins/index.css +551 -551
- package/dist/plugins/index.js +648 -703
- package/docs/api/{player.audioselector.md → player.audiotracks.md} +3 -3
- package/docs/api/player.clapprstats.exportmetrics.md +1 -1
- package/docs/api/player.clapprstats.md +5 -15
- package/docs/api/player.clapprstatssettings.md +13 -0
- package/docs/api/{player.contextmenupluginsettings.preventshowcontextmenu.md → player.clips.destroy.md} +7 -3
- package/docs/api/{player.contextmenupluginsettings.label.md → player.clips.disable.md} +7 -3
- package/docs/api/player.clips.enable.md +18 -0
- package/docs/api/player.clips.md +170 -0
- package/docs/api/player.clips.render.md +18 -0
- package/docs/api/player.clips.supportedversion.md +16 -0
- package/docs/api/player.clips.version.md +14 -0
- package/docs/api/player.clipspluginsettings.md +2 -2
- package/docs/api/player.clipspluginsettings.text.md +1 -1
- package/docs/api/player.contextmenu.md +2 -0
- package/docs/api/player.contextmenupluginsettings.md +2 -40
- package/docs/api/{player.contextmenupluginsettings.url.md → player.contextmenupluginsettings.options.md} +3 -3
- package/docs/api/player.md +101 -37
- package/docs/api/player.mediacontrol.md +9 -15
- package/docs/api/{player.mediacontrol.getelement.md → player.mediacontrol.mount.md} +20 -7
- package/docs/api/player.mediacontrolelement.md +4 -2
- package/docs/api/player.mediacontrollayerelement.md +16 -0
- package/docs/api/player.mediacontrolleftelement.md +16 -0
- package/docs/api/player.mediacontrolrightelement.md +16 -0
- package/docs/api/player.mediacontrolsettings.md +23 -0
- package/docs/api/player.menuoption.md +21 -0
- package/docs/api/{player.clapprnerdstats._constructor_.md → player.nerdstats._constructor_.md} +3 -3
- package/docs/api/{player.clapprnerdstats.md → player.nerdstats.md} +5 -5
- package/docs/api/player.playbackrate.md +1 -1
- package/docs/api/player.playerconfig.md +1 -1
- package/docs/api/player.playerconfig.playbacktype.md +1 -1
- package/docs/api/player.qualitylevel.height.md +1 -1
- package/docs/api/player.qualitylevel.level.md +1 -1
- package/docs/api/player.qualitylevel.md +4 -4
- package/docs/api/player.qualitylevel.width.md +1 -1
- package/docs/api/{player.levelselector.events.md → player.qualitylevels.events.md} +2 -2
- package/docs/api/{player.levelselector.md → player.qualitylevels.md} +6 -6
- package/docs/api/{player.levelselectorpluginsettings.labels.md → player.qualitylevelspluginsettings.labels.md} +2 -2
- package/docs/api/{player.levelselectorpluginsettings.md → player.qualitylevelspluginsettings.md} +6 -6
- package/docs/api/{player.levelselectorpluginsettings.restrictresolution.md → player.qualitylevelspluginsettings.restrictresolution.md} +2 -2
- package/docs/api/player.timeposition.current.md +1 -1
- package/docs/api/player.timeposition.md +2 -2
- package/docs/api/player.timeposition.total.md +1 -1
- package/docs/api/player.timeprogress.md +6 -4
- package/docs/api/player.timevalue.md +1 -1
- package/lib/index.plugins.d.ts +2 -1
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +2 -1
- package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.js +5 -7
- package/lib/playback.types.d.ts +22 -9
- package/lib/playback.types.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +4 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +20 -23
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +83 -0
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/NerdStats.js +339 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +27 -32
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/ClapprStats.js +94 -202
- package/lib/plugins/clappr-stats/types.d.ts +65 -24
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/types.js +37 -2
- package/lib/plugins/clappr-stats/utils.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/utils.js +1 -2
- package/lib/plugins/clips/Clips.d.ts +21 -16
- package/lib/plugins/clips/Clips.d.ts.map +1 -1
- package/lib/plugins/clips/Clips.js +96 -98
- package/lib/plugins/clips/types.d.ts +19 -0
- package/lib/plugins/clips/types.d.ts.map +1 -0
- package/lib/plugins/clips/types.js +1 -0
- package/lib/plugins/clips/utils.d.ts +4 -0
- package/lib/plugins/clips/utils.d.ts.map +1 -0
- package/lib/plugins/clips/utils.js +36 -0
- package/lib/plugins/media-control/MediaControl.d.ts +4 -7
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +19 -31
- package/lib/plugins/utils.d.ts +9 -1
- package/lib/plugins/utils.d.ts.map +1 -1
- package/lib/plugins/utils.js +9 -10
- package/lib/plugins/vast-ads/loaderxml.js +2 -2
- package/lib/testUtils.d.ts +2 -1
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +5 -7
- package/package.json +1 -1
- package/src/index.plugins.ts +2 -1
- package/src/playback/dash-playback/DashPlayback.ts +5 -8
- package/src/playback.types.ts +23 -8
- package/src/plugins/clappr-nerd-stats/{ClapprNerdStats.ts → NerdStats.ts} +25 -30
- package/src/plugins/clappr-stats/ClapprStats.ts +242 -306
- package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +133 -0
- package/src/plugins/clappr-stats/types.ts +72 -25
- package/src/plugins/clappr-stats/utils.ts +1 -2
- package/src/plugins/clips/Clips.ts +116 -135
- package/src/plugins/clips/__tests__/Clips.test.ts +72 -0
- package/src/plugins/clips/__tests__/__snapshots__/Clips.test.ts.snap +14 -0
- package/src/plugins/clips/types.ts +22 -0
- package/src/plugins/clips/utils.ts +54 -0
- package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +3 -4
- package/src/plugins/level-selector/__tests__/__snapshots__/QualityLevels.test.ts.snap +18 -18
- package/src/plugins/media-control/MediaControl.ts +31 -58
- package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +7 -35
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +1 -0
- package/src/plugins/utils.ts +9 -7
- package/src/plugins/vast-ads/loaderxml.ts +2 -2
- package/src/testUtils.ts +5 -7
- package/temp/player.api.json +693 -471
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.clapprstats.setupdatemetrics.md +0 -56
- package/docs/api/player.clipsplugin.gettext.md +0 -58
- package/docs/api/player.clipsplugin.md +0 -59
- package/docs/api/player.mediacontrol.handlecustomarea.md +0 -52
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { UICorePlugin, Events, template } from '@clappr/core';
|
|
2
|
+
import { reportError, trace } from '@gcorevideo/utils';
|
|
3
|
+
import Mousetrap from 'mousetrap';
|
|
4
|
+
import assert from 'assert';
|
|
5
|
+
import { CLAPPR_VERSION } from '../../build.js';
|
|
6
|
+
import { ClapprStatsEvents, } from '../clappr-stats/types.js';
|
|
7
|
+
import { newMetrics as newBaseMetrics } from '../clappr-stats/utils.js';
|
|
8
|
+
import Formatter from './formatter.js';
|
|
9
|
+
import { clearSpeedTestResults, configureSpeedTest, drawSpeedTestResults, initSpeedTest, startSpeedtest, stopSpeedtest, } from './speedtest/index.js';
|
|
10
|
+
import '../../../assets/clappr-nerd-stats/clappr-nerd-stats.scss';
|
|
11
|
+
import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs';
|
|
12
|
+
import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs';
|
|
13
|
+
import statsIcon from '../../../assets/icons/new/stats.svg';
|
|
14
|
+
import { GearEvents } from '../bottom-gear/BottomGear.js';
|
|
15
|
+
const qualityClasses = [
|
|
16
|
+
'speedtest-quality-value-1',
|
|
17
|
+
'speedtest-quality-value-2',
|
|
18
|
+
'speedtest-quality-value-3',
|
|
19
|
+
'speedtest-quality-value-4',
|
|
20
|
+
'speedtest-quality-value-5',
|
|
21
|
+
];
|
|
22
|
+
const getDownloadQuality = (speedValue) => {
|
|
23
|
+
if (speedValue < 3) {
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
else if (speedValue < 7) {
|
|
27
|
+
return 2;
|
|
28
|
+
}
|
|
29
|
+
else if (speedValue < 13) {
|
|
30
|
+
return 3;
|
|
31
|
+
}
|
|
32
|
+
else if (speedValue < 25) {
|
|
33
|
+
return 4;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return 5;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const getPingQuality = (pingValue) => {
|
|
40
|
+
if (pingValue < 20) {
|
|
41
|
+
return 5;
|
|
42
|
+
}
|
|
43
|
+
else if (pingValue < 50) {
|
|
44
|
+
return 4;
|
|
45
|
+
}
|
|
46
|
+
else if (pingValue < 100) {
|
|
47
|
+
return 3;
|
|
48
|
+
}
|
|
49
|
+
else if (pingValue < 150) {
|
|
50
|
+
return 2;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const generateQualityHtml = (quality) => {
|
|
57
|
+
const html = [];
|
|
58
|
+
const qualityClassName = qualityClasses[quality - 1];
|
|
59
|
+
for (let i = 0; i < qualityClasses.length; i++) {
|
|
60
|
+
if (i < quality) {
|
|
61
|
+
html.push(`<div class="speedtest-quality-content-item ${qualityClassName}"></div>`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
html.push('<div class="speedtest-quality-content-item"></div>');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return html.join('');
|
|
68
|
+
};
|
|
69
|
+
const drawSummary = (customMetrics, vodContainer, liveContainer) => {
|
|
70
|
+
const { connectionSpeed, ping } = customMetrics;
|
|
71
|
+
if (!connectionSpeed || !ping) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const downloadQuality = getDownloadQuality(connectionSpeed);
|
|
75
|
+
const pingQuality = getPingQuality(ping);
|
|
76
|
+
const liveQuality = Math.min(downloadQuality, pingQuality);
|
|
77
|
+
const vodHtml = generateQualityHtml(downloadQuality);
|
|
78
|
+
const liveHtml = generateQualityHtml(liveQuality);
|
|
79
|
+
vodContainer.html(vodHtml);
|
|
80
|
+
liveContainer.html(liveHtml);
|
|
81
|
+
};
|
|
82
|
+
const T = 'plugins.nerd_stats';
|
|
83
|
+
/**
|
|
84
|
+
* `PLUGIN` that displays useful network-related statistics.
|
|
85
|
+
* @beta
|
|
86
|
+
*
|
|
87
|
+
* @remarks
|
|
88
|
+
* Depends on:
|
|
89
|
+
*
|
|
90
|
+
* - {@link BottomGear}
|
|
91
|
+
*
|
|
92
|
+
* - {@link ClapprStats}
|
|
93
|
+
*
|
|
94
|
+
* The plugin is rendered as an item in the gear menu.
|
|
95
|
+
*
|
|
96
|
+
* When clicked, it shows an overlay window with the information about the network speed, latency, etc,
|
|
97
|
+
* and recommended quality level.
|
|
98
|
+
*/
|
|
99
|
+
export class NerdStats extends UICorePlugin {
|
|
100
|
+
container = null;
|
|
101
|
+
customMetrics = {
|
|
102
|
+
connectionSpeed: 0,
|
|
103
|
+
ping: 0,
|
|
104
|
+
jitter: 0,
|
|
105
|
+
};
|
|
106
|
+
metrics = newMetrics();
|
|
107
|
+
showing = false;
|
|
108
|
+
shortcut;
|
|
109
|
+
iconPosition;
|
|
110
|
+
static buttonTemplate = template(buttonHtml);
|
|
111
|
+
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
get name() {
|
|
115
|
+
return 'nerd_stats';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
get supportedVersion() {
|
|
121
|
+
return { min: CLAPPR_VERSION };
|
|
122
|
+
}
|
|
123
|
+
static template = template(pluginHtml);
|
|
124
|
+
/**
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
get attributes() {
|
|
128
|
+
return {
|
|
129
|
+
'data-clappr-nerd-stats': '',
|
|
130
|
+
class: 'clappr-nerd-stats',
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
get events() {
|
|
137
|
+
return {
|
|
138
|
+
'click [data-show-stats-button]': 'showOrHide',
|
|
139
|
+
'click [data-close-button]': 'hide',
|
|
140
|
+
'click [data-refresh-button]': 'refreshSpeedTest',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
get statsBoxElem() {
|
|
144
|
+
return '.clappr-nerd-stats[data-clappr-nerd-stats] .stats-box';
|
|
145
|
+
}
|
|
146
|
+
get statsBoxWidthThreshold() {
|
|
147
|
+
return 720;
|
|
148
|
+
}
|
|
149
|
+
get playerWidth() {
|
|
150
|
+
return this.core.$el.width();
|
|
151
|
+
}
|
|
152
|
+
get playerHeight() {
|
|
153
|
+
return this.core.$el.height();
|
|
154
|
+
}
|
|
155
|
+
constructor(core) {
|
|
156
|
+
super(core);
|
|
157
|
+
this.shortcut = core.options.clapprNerdStats?.shortcut ?? [
|
|
158
|
+
'command+shift+s',
|
|
159
|
+
'ctrl+shift+s',
|
|
160
|
+
];
|
|
161
|
+
this.iconPosition =
|
|
162
|
+
core.options.clapprNerdStats?.iconPosition ?? 'bottom-right';
|
|
163
|
+
this.customMetrics = {
|
|
164
|
+
connectionSpeed: 0,
|
|
165
|
+
ping: 0,
|
|
166
|
+
jitter: 0,
|
|
167
|
+
};
|
|
168
|
+
configureSpeedTest(core.options.clapprNerdStats?.speedTestServers ?? []);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
bindEvents() {
|
|
174
|
+
this.listenToOnce(this.core, Events.CORE_READY, this.onCoreReady);
|
|
175
|
+
}
|
|
176
|
+
onCoreReady() {
|
|
177
|
+
const bottomGear = this.core.getPlugin('bottom_gear');
|
|
178
|
+
assert(bottomGear, 'bottom_gear plugin is required');
|
|
179
|
+
this.listenTo(bottomGear, GearEvents.RENDERED, this.addToBottomGear);
|
|
180
|
+
this.container = this.core.activeContainer;
|
|
181
|
+
const clapprStats = this.container?.getPlugin('clappr_stats');
|
|
182
|
+
assert(clapprStats, 'clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
|
|
183
|
+
'For more info, visit: https://github.com/clappr/clappr-stats.');
|
|
184
|
+
Mousetrap.bind(this.shortcut, this.toggle);
|
|
185
|
+
this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize);
|
|
186
|
+
this.listenTo(clapprStats, ClapprStatsEvents.REPORT, this.updateMetrics);
|
|
187
|
+
this.updateMetrics(clapprStats.exportMetrics());
|
|
188
|
+
this.render();
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
destroy() {
|
|
194
|
+
Mousetrap.unbind(this.shortcut);
|
|
195
|
+
return super.destroy();
|
|
196
|
+
}
|
|
197
|
+
toggle = () => {
|
|
198
|
+
if (this.showing) {
|
|
199
|
+
this.hide();
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.show();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
show() {
|
|
206
|
+
this.core.$el.find(this.statsBoxElem).show();
|
|
207
|
+
this.showing = true;
|
|
208
|
+
this.refreshSpeedTest();
|
|
209
|
+
initSpeedTest(this.customMetrics)
|
|
210
|
+
.then(() => {
|
|
211
|
+
startSpeedtest();
|
|
212
|
+
})
|
|
213
|
+
.catch((e) => {
|
|
214
|
+
reportError(e);
|
|
215
|
+
this.disable();
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
hide() {
|
|
219
|
+
this.core.$el.find(this.statsBoxElem).hide();
|
|
220
|
+
this.showing = false;
|
|
221
|
+
stopSpeedtest();
|
|
222
|
+
}
|
|
223
|
+
onPlayerResize() {
|
|
224
|
+
this.setStatsBoxSize();
|
|
225
|
+
}
|
|
226
|
+
addGeneralMetrics() {
|
|
227
|
+
this.metrics.general = {
|
|
228
|
+
displayResolution: this.playerWidth + 'x' + this.playerHeight,
|
|
229
|
+
volume: this.container?.volume,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
addCustomMetrics() {
|
|
233
|
+
this.metrics.custom = this.customMetrics;
|
|
234
|
+
const videoQualityNames = [
|
|
235
|
+
'SD (480p)',
|
|
236
|
+
'HD (720p)',
|
|
237
|
+
'Full HD (1080p)',
|
|
238
|
+
'2K (1440p)',
|
|
239
|
+
'4K (2160p)',
|
|
240
|
+
];
|
|
241
|
+
const { connectionSpeed, ping } = this.customMetrics;
|
|
242
|
+
if (!connectionSpeed || !ping) {
|
|
243
|
+
const calculatingText = 'Calculating... Please wait.';
|
|
244
|
+
this.metrics.custom.vodQuality = calculatingText;
|
|
245
|
+
this.metrics.custom.liveQuality = calculatingText;
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const downloadQuality = getDownloadQuality(connectionSpeed);
|
|
249
|
+
const pingQuality = getPingQuality(ping);
|
|
250
|
+
const liveQuality = Math.min(downloadQuality, pingQuality);
|
|
251
|
+
const prefix = 'Optimal for ';
|
|
252
|
+
this.metrics.custom.vodQuality =
|
|
253
|
+
prefix + videoQualityNames[downloadQuality - 1];
|
|
254
|
+
this.metrics.custom.liveQuality =
|
|
255
|
+
prefix + videoQualityNames[liveQuality - 1];
|
|
256
|
+
}
|
|
257
|
+
updateMetrics(metrics) {
|
|
258
|
+
Object.assign(this.metrics, metrics);
|
|
259
|
+
this.addGeneralMetrics();
|
|
260
|
+
this.addCustomMetrics();
|
|
261
|
+
const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop();
|
|
262
|
+
this.$el.html(NerdStats.template({
|
|
263
|
+
metrics: Formatter.format(this.metrics),
|
|
264
|
+
iconPosition: this.iconPosition,
|
|
265
|
+
}));
|
|
266
|
+
this.setStatsBoxSize();
|
|
267
|
+
drawSpeedTestResults();
|
|
268
|
+
drawSummary(this.metrics?.custom, this.$el.find('.speedtest-quality-content[data-streaming-type="vod"]'), this.$el.find('.speedtest-quality-content[data-streaming-type="live"]'));
|
|
269
|
+
this.core.$el.find(this.statsBoxElem).scrollTop(scrollTop);
|
|
270
|
+
if (!this.showing) {
|
|
271
|
+
this.hide();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
setStatsBoxSize() {
|
|
275
|
+
if (this.playerWidth >= this.statsBoxWidthThreshold) {
|
|
276
|
+
this.$el.find(this.statsBoxElem).addClass('wide');
|
|
277
|
+
this.$el.find(this.statsBoxElem).removeClass('narrow');
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
this.$el.find(this.statsBoxElem).removeClass('wide');
|
|
281
|
+
this.$el.find(this.statsBoxElem).addClass('narrow');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @internal
|
|
286
|
+
*/
|
|
287
|
+
render() {
|
|
288
|
+
trace(`${T} render`);
|
|
289
|
+
// TODO append to the container
|
|
290
|
+
this.core.$el.append(this.$el[0]);
|
|
291
|
+
this.hide();
|
|
292
|
+
return this;
|
|
293
|
+
}
|
|
294
|
+
addToBottomGear() {
|
|
295
|
+
trace(`${T} addToBottomGear`);
|
|
296
|
+
const gear = this.core.getPlugin('bottom_gear');
|
|
297
|
+
gear
|
|
298
|
+
.addItem('nerd_stats')
|
|
299
|
+
.html(NerdStats.buttonTemplate({
|
|
300
|
+
icon: statsIcon,
|
|
301
|
+
i18n: this.core.i18n,
|
|
302
|
+
}))
|
|
303
|
+
.on('click', (e) => {
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
this.toggle();
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
clearCustomMetrics() {
|
|
309
|
+
const clapprStats = this.container?.getPlugin('clappr_stats');
|
|
310
|
+
this.customMetrics.connectionSpeed = 0;
|
|
311
|
+
this.customMetrics.ping = 0;
|
|
312
|
+
this.customMetrics.jitter = 0;
|
|
313
|
+
if (clapprStats) {
|
|
314
|
+
this.updateMetrics(clapprStats.exportMetrics());
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
refreshSpeedTest() {
|
|
318
|
+
stopSpeedtest();
|
|
319
|
+
setTimeout(() => {
|
|
320
|
+
this.clearCustomMetrics();
|
|
321
|
+
clearSpeedTestResults();
|
|
322
|
+
drawSpeedTestResults();
|
|
323
|
+
}, 200);
|
|
324
|
+
setTimeout(() => {
|
|
325
|
+
startSpeedtest();
|
|
326
|
+
}, 800);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function newMetrics() {
|
|
330
|
+
return {
|
|
331
|
+
...newBaseMetrics(),
|
|
332
|
+
general: {},
|
|
333
|
+
custom: {
|
|
334
|
+
connectionSpeed: 0,
|
|
335
|
+
ping: 0,
|
|
336
|
+
jitter: 0,
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
}
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { Container, ContainerPlugin } from '@clappr/core';
|
|
2
|
-
import type { Metrics
|
|
2
|
+
import type { Metrics } from './types.js';
|
|
3
|
+
export type ClapprStatsSettings = {
|
|
4
|
+
/**
|
|
5
|
+
* The interval in milliseconds of periodic measurements.
|
|
6
|
+
* The plugin will emit a {@link ClapprStatsEvents.REPORT} event with the collected metrics at the specified interval.
|
|
7
|
+
*/
|
|
8
|
+
runEach?: number;
|
|
9
|
+
};
|
|
3
10
|
/**
|
|
4
|
-
* `PLUGIN` that
|
|
11
|
+
* `PLUGIN` that measures data about playback, which can be useful for analyzing performance and UX.
|
|
5
12
|
* @beta
|
|
6
13
|
* @remarks
|
|
7
14
|
* This plugin does not render anything and is supposed to be extended or used together with other plugins that actually render something.
|
|
15
|
+
*
|
|
16
|
+
* Configuration options - {@link ClapprStatsSettings}
|
|
17
|
+
*
|
|
18
|
+
* Events - {@link ClapprStatsEvents}
|
|
8
19
|
*/
|
|
9
20
|
export declare class ClapprStats extends ContainerPlugin {
|
|
10
|
-
private
|
|
11
|
-
private intervalId;
|
|
21
|
+
private timerId;
|
|
12
22
|
private lastDecodedFramesCount;
|
|
13
23
|
private metrics;
|
|
14
|
-
private completion;
|
|
15
|
-
private _onReport;
|
|
16
|
-
private runBandwidthTestEvery;
|
|
17
|
-
private runEach;
|
|
18
24
|
private timers;
|
|
19
|
-
private
|
|
20
|
-
private urisToMeasureBandwidth;
|
|
21
|
-
private uriToMeasureLatency;
|
|
25
|
+
private runEach;
|
|
22
26
|
/**
|
|
23
27
|
* @internal
|
|
24
28
|
*/
|
|
@@ -29,18 +33,12 @@ export declare class ClapprStats extends ContainerPlugin {
|
|
|
29
33
|
get supportedVersion(): {
|
|
30
34
|
min: string;
|
|
31
35
|
};
|
|
32
|
-
private get
|
|
33
|
-
private get
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
+
private get playbackName();
|
|
37
|
+
private get playbackType();
|
|
38
|
+
private now;
|
|
39
|
+
private inc;
|
|
36
40
|
private start;
|
|
37
|
-
private
|
|
38
|
-
/**
|
|
39
|
-
* Registers a callback to receive the metrics.
|
|
40
|
-
* @param updateMetricsFn - The callback to receive the metrics
|
|
41
|
-
*/
|
|
42
|
-
setUpdateMetrics(updateMetricsFn: MetricsUpdateFn): void;
|
|
43
|
-
private _defaultReport;
|
|
41
|
+
private stop;
|
|
44
42
|
constructor(container: Container);
|
|
45
43
|
/**
|
|
46
44
|
* @internal
|
|
@@ -52,7 +50,7 @@ export declare class ClapprStats extends ContainerPlugin {
|
|
|
52
50
|
destroy(): void;
|
|
53
51
|
/**
|
|
54
52
|
* Returns the collected metrics.
|
|
55
|
-
* @returns
|
|
53
|
+
* @returns Measurements collected so far
|
|
56
54
|
*/
|
|
57
55
|
exportMetrics(): Metrics;
|
|
58
56
|
private onBitrate;
|
|
@@ -68,14 +66,11 @@ export declare class ClapprStats extends ContainerPlugin {
|
|
|
68
66
|
private onBuffering;
|
|
69
67
|
private onBufferfull;
|
|
70
68
|
private onProgress;
|
|
71
|
-
private
|
|
72
|
-
private
|
|
73
|
-
private
|
|
74
|
-
private
|
|
75
|
-
private
|
|
76
|
-
private
|
|
77
|
-
private _html5FetchFPS;
|
|
78
|
-
private _measureLatency;
|
|
79
|
-
private _measureBandwidth;
|
|
69
|
+
private onCompletion;
|
|
70
|
+
private buildReport;
|
|
71
|
+
private fetchFPS;
|
|
72
|
+
private calcBitrates;
|
|
73
|
+
private calcBufferingPercentage;
|
|
74
|
+
private html5FetchFPS;
|
|
80
75
|
}
|
|
81
76
|
//# sourceMappingURL=ClapprStats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClapprStats.d.ts","sourceRoot":"","sources":["../../../src/plugins/clappr-stats/ClapprStats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"ClapprStats.d.ts","sourceRoot":"","sources":["../../../src/plugins/clappr-stats/ClapprStats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAwB,MAAM,cAAc,CAAA;AAU/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAIzC,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;;GASG;AACH,qBAAa,WAAY,SAAQ,eAAe;IAC9C,OAAO,CAAC,OAAO,CAAuB;IAEtC,OAAO,CAAC,sBAAsB,CAAI;IAElC,OAAO,CAAC,OAAO,CAAwB;IAEvC,OAAO,CAAC,MAAM,CAMb;IAED,OAAO,CAAC,OAAO,CAAQ;IAEvB;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED,OAAO,KAAK,YAAY,GAEvB;IAED,OAAO,KAAK,YAAY,GAEvB;IAED,OAAO,CAAC,GAAG;IASX,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,IAAI;gBAKA,SAAS,EAAE,SAAS;IAKhC;;OAEG;IACM,UAAU;IAmDnB;;OAEG;IACM,OAAO;IAKhB;;;OAGG;IACH,aAAa;IAIb,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,OAAO;IAgBf,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,6BAA6B;IAOrC,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,QAAQ;IAgBhB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,aAAa;CA0BtB"}
|