@gcorevideo/player 2.28.3 → 2.28.4
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/dist/core.js +1 -1
- package/dist/index.css +459 -459
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/coverage/clover.xml +0 -6
- package/coverage/coverage-final.json +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -101
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -0
- package/dist/player.d.ts +0 -3369
- package/lib/playback/utils.d.ts +0 -2
- package/lib/playback/utils.d.ts.map +0 -1
- package/lib/playback/utils.js +0 -1
- package/lib/plugins/audio-selector/AudioSelector.d.ts +0 -67
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +0 -1
- package/lib/plugins/audio-selector/AudioSelector.js +0 -172
- package/lib/plugins/build.d.ts +0 -2
- package/lib/plugins/build.d.ts.map +0 -1
- package/lib/plugins/build.js +0 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +0 -83
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +0 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +0 -339
- package/lib/plugins/disable-controls/DisableControls.d.ts +0 -15
- package/lib/plugins/disable-controls/DisableControls.d.ts.map +0 -1
- package/lib/plugins/disable-controls/DisableControls.js +0 -67
- package/lib/plugins/index.d.ts +0 -35
- package/lib/plugins/index.d.ts.map +0 -1
- package/lib/plugins/index.js +0 -37
- package/lib/plugins/level-selector/LevelSelector.d.ts +0 -112
- package/lib/plugins/level-selector/LevelSelector.d.ts.map +0 -1
- package/lib/plugins/level-selector/LevelSelector.js +0 -280
- package/lib/plugins/statistics/Statistics.d.ts +0 -87
- package/lib/plugins/statistics/Statistics.d.ts.map +0 -1
- package/lib/plugins/statistics/Statistics.js +0 -172
- package/lib/plugins/subtitles/Subtitles.d.ts +0 -115
- package/lib/plugins/subtitles/Subtitles.d.ts.map +0 -1
- package/lib/plugins/subtitles/Subtitles.js +0 -345
- package/lib/tsdoc-metadata.json +0 -11
- package/lib/utils/fullscreen.d.ts +0 -3
- package/lib/utils/fullscreen.d.ts.map +0 -1
- package/lib/utils/fullscreen.js +0 -2
- package/release.txt +0 -395
- package/release_notes +0 -297
- package/src/plugins/telemetry/Statistics copy.js +0 -296
- package/temp/player.api.json +0 -10275
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { Browser, Container, ContainerPlugin, Events, Playback } from '@clappr/core';
|
|
2
|
-
// import type { GcoreStreamMediaSource, TimePosition } from '@gcorevideo/player';
|
|
3
|
-
import type { TimePosition } from '@gcorevideo/player';
|
|
4
|
-
import { reportError } from '@gcorevideo/utils';
|
|
5
|
-
import Fingerprint from '@fingerprintjs/fingerprintjs'; // TODO drop
|
|
6
|
-
import { Events as HlsEvents, FragChangedData } from 'hls.js';
|
|
7
|
-
|
|
8
|
-
import { CLAPPR_VERSION } from '../build.js';
|
|
9
|
-
|
|
10
|
-
type MediaSourceInfo = {
|
|
11
|
-
id: number;
|
|
12
|
-
source: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class Statistics extends ContainerPlugin {
|
|
16
|
-
get name() {
|
|
17
|
-
return 'statistics_gplayer';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get supportedVersion() {
|
|
21
|
-
return { min: CLAPPR_VERSION };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private socketOpen = false;
|
|
25
|
-
|
|
26
|
-
private init = false;
|
|
27
|
-
|
|
28
|
-
private started = false;
|
|
29
|
-
|
|
30
|
-
private played = false;
|
|
31
|
-
|
|
32
|
-
private playerReady = false;
|
|
33
|
-
|
|
34
|
-
private prevTimeCurrent = 0;
|
|
35
|
-
|
|
36
|
-
private firstHeatmapSent = false;
|
|
37
|
-
|
|
38
|
-
private isLiveWatchSent = false;
|
|
39
|
-
|
|
40
|
-
private countBufferAvailable = false;
|
|
41
|
-
|
|
42
|
-
private startTimeRepeatableRoll = 0;
|
|
43
|
-
|
|
44
|
-
private heatmapCounter = 1;
|
|
45
|
-
|
|
46
|
-
private lags = 0;
|
|
47
|
-
|
|
48
|
-
private bufferStartTime = 0;
|
|
49
|
-
|
|
50
|
-
private bufferComputeTime = 0;
|
|
51
|
-
|
|
52
|
-
private url = '';
|
|
53
|
-
|
|
54
|
-
private uuid = '';
|
|
55
|
-
|
|
56
|
-
private socket: WebSocket | null = null;
|
|
57
|
-
|
|
58
|
-
private startTime = 0;
|
|
59
|
-
|
|
60
|
-
private streamID = 0;
|
|
61
|
-
|
|
62
|
-
constructor(container: Container) {
|
|
63
|
-
super(container);
|
|
64
|
-
this.connect();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override bindEvents() {
|
|
68
|
-
this.listenToOnce(this.container.playback, Events.PLAYBACK_PLAY, this.onPlay);
|
|
69
|
-
this.listenToOnce(this.container, 'container:start', this.onStart);
|
|
70
|
-
|
|
71
|
-
this.listenToOnce(this.container, Events.CONTAINER_READY, this.onReady);
|
|
72
|
-
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERING, this.onBuffering);
|
|
73
|
-
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERFULL, this.onBufferFull);
|
|
74
|
-
this.listenTo(this.container.playback, Events.PLAYBACK_TIMEUPDATE, this.onTimeUpdate);
|
|
75
|
-
this.listenTo(this.container.playback, Events.PLAYBACK_TIMEUPDATE, this.onTimeUpdateLive);
|
|
76
|
-
this.listenTo(this.container.playback, Events.PLAYBACK_LEVEL_SWITCH_START, this.startLevelSwitch);
|
|
77
|
-
this.listenTo(this.container.playback, Events.PLAYBACK_LEVEL_SWITCH_END, this.stopLevelSwitch);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private startLevelSwitch() {
|
|
81
|
-
this.countBufferAvailable = false;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private stopLevelSwitch() {
|
|
85
|
-
this.countBufferAvailable = true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private onBuffering() {
|
|
89
|
-
if (this.countBufferAvailable) {
|
|
90
|
-
this.bufferStartTime = performance.now();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private onBufferFull() {
|
|
95
|
-
if (this.countBufferAvailable && this.bufferStartTime) {
|
|
96
|
-
this.bufferComputeTime += Math.round(performance.now() - this.bufferStartTime);
|
|
97
|
-
this.lags++;
|
|
98
|
-
}
|
|
99
|
-
this.countBufferAvailable = true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private connect() {
|
|
103
|
-
try {
|
|
104
|
-
if (!this.options.statistics.url) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
} catch (error) {
|
|
108
|
-
reportError(error);
|
|
109
|
-
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this.removeSocket();
|
|
113
|
-
this.url = this.options.statistics.url;
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
this.socket = new WebSocket(this.url);
|
|
117
|
-
this.socket.onopen = this.openHandler;
|
|
118
|
-
this.socket.onclose = this.closeHandler;
|
|
119
|
-
this.socket.onerror = this.errorHandler;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
reportError(error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private openHandler = () => {
|
|
126
|
-
this.socketOpen = true;
|
|
127
|
-
if (this.playerReady && !this.init) {
|
|
128
|
-
this.initEvent();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private closeHandler = () => {}
|
|
133
|
-
|
|
134
|
-
private errorHandler = () => {}
|
|
135
|
-
|
|
136
|
-
private removeSocket() {
|
|
137
|
-
if (this.socket) {
|
|
138
|
-
this.socket.onopen = null;
|
|
139
|
-
this.socket.onclose = null;
|
|
140
|
-
this.socket.onmessage = null;
|
|
141
|
-
this.socket.onerror = null;
|
|
142
|
-
this.socket.close();
|
|
143
|
-
this.socket = null;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private onReady() {
|
|
148
|
-
this.playerReady = true;
|
|
149
|
-
const element = this.findElementBySource(this.options.source);
|
|
150
|
-
|
|
151
|
-
if (!element) {
|
|
152
|
-
this.destroy();
|
|
153
|
-
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
Fingerprint.load()
|
|
157
|
-
.then(agent => agent.get())
|
|
158
|
-
.then((res) => {
|
|
159
|
-
this.uuid = res.visitorId;
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
this.streamID = element.id;
|
|
163
|
-
|
|
164
|
-
if (this.socketOpen && !this.init) {
|
|
165
|
-
this.initEvent();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
private findElementBySource(source: string): MediaSourceInfo | undefined {
|
|
170
|
-
return this.options.multisources.find((s: MediaSourceInfo) => s.source === source);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
private initEvent() {
|
|
174
|
-
this.init = true;
|
|
175
|
-
this.sendMessage('init');
|
|
176
|
-
if (this.options.autoPlay) {
|
|
177
|
-
this.container.trigger('container:start');
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private sendMessage(state: 'init' | 'start' | 'watch') {
|
|
182
|
-
this.send(JSON.stringify({
|
|
183
|
-
event: state,
|
|
184
|
-
type: this.container.getPlaybackType(),
|
|
185
|
-
embed_url: this.options.referer,
|
|
186
|
-
user_agent: Browser.userAgent
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private send(str: string) {
|
|
191
|
-
if (this.socket) {
|
|
192
|
-
this.socket.send(str);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
private onTimeUpdateLive() {
|
|
197
|
-
if (!this.streamID) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
let currentTime = 0;
|
|
202
|
-
|
|
203
|
-
try {
|
|
204
|
-
let startTime = this.startTimeRepeatableRoll;
|
|
205
|
-
|
|
206
|
-
if (!this.startTimeRepeatableRoll) {
|
|
207
|
-
if (!startTime) {
|
|
208
|
-
this.startTimeRepeatableRoll = startTime = this.container.playback.el.currentTime;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
currentTime = this.container.playback.el.currentTime - startTime;
|
|
213
|
-
this.played = true;
|
|
214
|
-
|
|
215
|
-
if (this.started && this.played && !this.firstHeatmapSent && Math.floor(currentTime) === 0) {
|
|
216
|
-
this.firstHeatmapSent = true;
|
|
217
|
-
this.sendHeatmap();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (currentTime > 0 && Math.floor(currentTime / 10) === 1 && this.uuid) {
|
|
221
|
-
this.sendHeatmap();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (this.container.getPlaybackType() === Playback.LIVE && !this.isLiveWatchSent && currentTime >= 5) {
|
|
225
|
-
this.isLiveWatchSent = true;
|
|
226
|
-
this.sendMessage('watch');
|
|
227
|
-
}
|
|
228
|
-
} catch (error) {
|
|
229
|
-
reportError(error);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private sendHeatmap() {
|
|
234
|
-
this.startTimeRepeatableRoll = this.container.playback.el.currentTime;
|
|
235
|
-
const res: Record<string, unknown> = {
|
|
236
|
-
'event': 'heatmap',
|
|
237
|
-
'uniq_id': this.uuid,
|
|
238
|
-
'type': this.container.getPlaybackType(),
|
|
239
|
-
'stream_id': this.streamID,
|
|
240
|
-
lags: this.lags,
|
|
241
|
-
buffering: this.bufferComputeTime,
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
this.bufferComputeTime = 0;
|
|
245
|
-
this.lags = 0;
|
|
246
|
-
if (this.container.getPlaybackType() === Playback.VOD) {
|
|
247
|
-
res.timestamp = this.container.playback.el.currentTime;
|
|
248
|
-
}
|
|
249
|
-
this.send(JSON.stringify(res));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private onTimeUpdate({ current }: TimePosition) {
|
|
253
|
-
if (this.container.getPlaybackType() === Playback.LIVE) {
|
|
254
|
-
this.stopListening(this.container.playback, Events.PLAYBACK_TIMEUPDATE, this.onTimeUpdate);
|
|
255
|
-
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (!this.prevTimeCurrent) {
|
|
260
|
-
this.prevTimeCurrent = current;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (Math.abs(this.prevTimeCurrent - current) > 5 && this.socketOpen) {
|
|
264
|
-
this.stopListening(this.container.playback, Events.PLAYBACK_TIMEUPDATE, this.onTimeUpdate);
|
|
265
|
-
this.sendMessage('watch');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
private onStart() {
|
|
270
|
-
this.sendMessage('start');
|
|
271
|
-
this.started = true;
|
|
272
|
-
if (this.started && this.played && !this.firstHeatmapSent) {
|
|
273
|
-
this.firstHeatmapSent = true;
|
|
274
|
-
this.sendHeatmap();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
private onPlay() {
|
|
279
|
-
try {
|
|
280
|
-
if (this.container.playback._hls) {
|
|
281
|
-
this.container.playback._hls.on(HlsEvents.FRAG_CHANGED, (_: HlsEvents.FRAG_CHANGED, b: FragChangedData) => {
|
|
282
|
-
if (this.options.debug === 'hls') {
|
|
283
|
-
console.warn(b.frag);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
} catch (error) {
|
|
288
|
-
reportError(error);
|
|
289
|
-
}
|
|
290
|
-
if (this.startTime) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
this.startTime = new Date().getTime();
|
|
295
|
-
}
|
|
296
|
-
}
|