@gcorevideo/player 2.28.16 → 2.28.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.
- package/dist/core.js +1 -1
- package/dist/index.css +154 -154
- package/dist/index.embed.js +74 -41
- package/dist/index.js +94 -51
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/NerdStats.js +10 -2
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/speedtest/index.js +14 -3
- package/lib/plugins/media-control/MediaControl.d.ts +1 -3
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +47 -22
- package/package.json +1 -1
- package/src/plugins/clappr-nerd-stats/NerdStats.ts +10 -2
- package/src/plugins/clappr-nerd-stats/speedtest/index.ts +15 -3
- package/src/plugins/media-control/MediaControl.ts +54 -27
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -285,8 +285,8 @@ export class MediaControl extends UICorePlugin {
|
|
|
285
285
|
this.listenTo(this.core, Events.CORE_FULLSCREEN, this.show);
|
|
286
286
|
this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.configure);
|
|
287
287
|
this.listenTo(this.core, Events.CORE_RESIZE, this.playerResize);
|
|
288
|
-
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
289
|
-
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
288
|
+
// this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
289
|
+
// this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
290
290
|
// const has360 = this.core?.getPlugin('video_360');
|
|
291
291
|
// if (Browser.isiOS && has360) {
|
|
292
292
|
// this.container?.el.addEventListener('click', e => {
|
|
@@ -312,6 +312,9 @@ export class MediaControl extends UICorePlugin {
|
|
|
312
312
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_PAUSE, this.changeTogglePlay);
|
|
313
313
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_STOP, this.changeTogglePlay);
|
|
314
314
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_DBLCLICK, this.toggleFullscreen);
|
|
315
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_CLICK, () => {
|
|
316
|
+
this.clickaway(this.core.activeContainer.$el[0]);
|
|
317
|
+
});
|
|
315
318
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_TIMEUPDATE, this.onTimeUpdate);
|
|
316
319
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_PROGRESS, this.updateProgressBar);
|
|
317
320
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_SETTINGSUPDATE, this.updateSettings);
|
|
@@ -328,6 +331,9 @@ export class MediaControl extends UICorePlugin {
|
|
|
328
331
|
});
|
|
329
332
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_MOUSE_ENTER, this.show);
|
|
330
333
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_MOUSE_LEAVE, this.delayHide);
|
|
334
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_DESTROYED, () => {
|
|
335
|
+
this.clickaway(null);
|
|
336
|
+
});
|
|
331
337
|
}
|
|
332
338
|
/**
|
|
333
339
|
* Hides the media control UI
|
|
@@ -336,12 +342,16 @@ export class MediaControl extends UICorePlugin {
|
|
|
336
342
|
this.userDisabled = true; // TODO distinguish between user and system (e.g., unplayable) disabled?
|
|
337
343
|
this.hide();
|
|
338
344
|
this.unbindKeyEvents();
|
|
339
|
-
this.$el.hide();
|
|
345
|
+
this.$el.hide();
|
|
340
346
|
}
|
|
341
347
|
/**
|
|
342
348
|
* Reenables the plugin disabled earlier with the {@link MediaControl.disable} method
|
|
343
349
|
*/
|
|
344
350
|
enable() {
|
|
351
|
+
trace(`${T} enable`, {
|
|
352
|
+
chromeless: this.options.chromeless,
|
|
353
|
+
userDisabled: this.userDisabled,
|
|
354
|
+
});
|
|
345
355
|
if (this.options.chromeless) {
|
|
346
356
|
return;
|
|
347
357
|
}
|
|
@@ -749,15 +759,26 @@ export class MediaControl extends UICorePlugin {
|
|
|
749
759
|
this.setSeekPercentage(pos);
|
|
750
760
|
}
|
|
751
761
|
setUserKeepVisible() {
|
|
762
|
+
trace(`${T} setUserKeepVisible`, {
|
|
763
|
+
userKeepVisible: this.userKeepVisible,
|
|
764
|
+
});
|
|
752
765
|
this.userKeepVisible = true;
|
|
753
766
|
}
|
|
754
|
-
resetUserKeepVisible() {
|
|
767
|
+
resetUserKeepVisible = () => {
|
|
768
|
+
trace(`${T} resetUserKeepVisible`, {
|
|
769
|
+
userKeepVisible: this.userKeepVisible,
|
|
770
|
+
});
|
|
755
771
|
this.userKeepVisible = false;
|
|
756
|
-
}
|
|
772
|
+
};
|
|
757
773
|
isVisible() {
|
|
758
774
|
return !this.$el.hasClass('media-control-hide');
|
|
759
775
|
}
|
|
760
776
|
show(event) {
|
|
777
|
+
trace(`${T} show`, {
|
|
778
|
+
disabled: this.disabled,
|
|
779
|
+
disableControlPanel: this.options.disableControlPanel,
|
|
780
|
+
event,
|
|
781
|
+
});
|
|
761
782
|
if (this.disabled || this.options.disableControlPanel) {
|
|
762
783
|
return;
|
|
763
784
|
}
|
|
@@ -1196,23 +1217,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
1196
1217
|
}
|
|
1197
1218
|
this.resetUserKeepVisible();
|
|
1198
1219
|
}
|
|
1199
|
-
// TODO manage by the ads plugin
|
|
1200
|
-
onStartAd() {
|
|
1201
|
-
// this.advertisementPlaying = true
|
|
1202
|
-
this.disable();
|
|
1203
|
-
}
|
|
1204
|
-
// TODO manage by the ads plugin
|
|
1205
|
-
onFinishAd() {
|
|
1206
|
-
// this.advertisementPlaying = false
|
|
1207
|
-
this.enable();
|
|
1208
|
-
}
|
|
1209
|
-
// TODO remove
|
|
1210
|
-
hideControllAds() {
|
|
1211
|
-
if (this.container.advertisement &&
|
|
1212
|
-
this.container.advertisement.type !== 'idle') {
|
|
1213
|
-
this.hide();
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
1220
|
static getPageX(event) {
|
|
1217
1221
|
return getPageX(event);
|
|
1218
1222
|
}
|
|
@@ -1259,6 +1263,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
1259
1263
|
});
|
|
1260
1264
|
this.hide(this.options.hideMediaControlDelay || DEFAULT_HIDE_DELAY);
|
|
1261
1265
|
}
|
|
1266
|
+
clickaway = clickaway(this.resetUserKeepVisible);
|
|
1262
1267
|
}
|
|
1263
1268
|
MediaControl.extend = function (properties) {
|
|
1264
1269
|
return extend(MediaControl, properties);
|
|
@@ -1299,3 +1304,23 @@ function mergeElements(a, b) {
|
|
|
1299
1304
|
return acc;
|
|
1300
1305
|
}, a);
|
|
1301
1306
|
}
|
|
1307
|
+
function clickaway(callback) {
|
|
1308
|
+
let handler = (event) => { };
|
|
1309
|
+
return (node) => {
|
|
1310
|
+
window.removeEventListener('click', handler);
|
|
1311
|
+
if (!node) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
handler = (event) => {
|
|
1315
|
+
trace(`${T} clickaway`, {
|
|
1316
|
+
node,
|
|
1317
|
+
event,
|
|
1318
|
+
});
|
|
1319
|
+
if (!node.contains(event.target)) {
|
|
1320
|
+
callback();
|
|
1321
|
+
window.removeEventListener('click', handler);
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
window.addEventListener('click', handler);
|
|
1325
|
+
};
|
|
1326
|
+
}
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ import statsIcon from '../../../assets/icons/new/stats.svg'
|
|
|
35
35
|
import { BottomGear, GearEvents } from '../bottom-gear/BottomGear.js'
|
|
36
36
|
import { drawSummary, getPingQuality } from './utils.js'
|
|
37
37
|
import { getDownloadQuality } from './utils.js'
|
|
38
|
+
import { trace } from '@gcorevideo/utils'
|
|
38
39
|
|
|
39
40
|
const PLAYBACK_NAMES: Record<string, string> = {
|
|
40
41
|
dash: 'DASH.js',
|
|
@@ -59,7 +60,7 @@ type Metrics = PerfMetrics & {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
const T = 'plugins.nerd_stats'
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
66
|
* `PLUGIN` that displays useful statistics regarding the playback as well as the network quality estimation.
|
|
@@ -233,6 +234,9 @@ export class NerdStats extends UICorePlugin {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
private toggle = () => {
|
|
237
|
+
trace(`${T} toggle`, {
|
|
238
|
+
open: this.open,
|
|
239
|
+
})
|
|
236
240
|
if (this.open) {
|
|
237
241
|
this.hide()
|
|
238
242
|
} else {
|
|
@@ -242,7 +246,7 @@ export class NerdStats extends UICorePlugin {
|
|
|
242
246
|
|
|
243
247
|
private show() {
|
|
244
248
|
this.$el.show()
|
|
245
|
-
this.statsBoxElem.scrollTop(this.statsBoxElem
|
|
249
|
+
this.statsBoxElem.scrollTop(this.statsBoxElem?.scrollTop())
|
|
246
250
|
this.open = true
|
|
247
251
|
|
|
248
252
|
initSpeedTest(this.speedtestMetrics)
|
|
@@ -251,11 +255,15 @@ export class NerdStats extends UICorePlugin {
|
|
|
251
255
|
})
|
|
252
256
|
.catch((e) => {
|
|
253
257
|
reportError(e)
|
|
258
|
+
trace(`${T} speedtest error`, {
|
|
259
|
+
error: e,
|
|
260
|
+
})
|
|
254
261
|
this.disable()
|
|
255
262
|
})
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
private hide() {
|
|
266
|
+
trace(`${T} hide`)
|
|
259
267
|
this.$el.hide()
|
|
260
268
|
this.open = false
|
|
261
269
|
stopSpeedtest()
|
|
@@ -122,12 +122,14 @@ export const initSpeedTest = (customMetrics: SpeedtestMetrics): Promise<void> =>
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
// getElementById('dlText').textContent = DEFAULT_DOWNLOAD_SPEED;
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
const myinfoUrl = 'https://gcore.com/.well-known/cdn-debug/json'
|
|
127
|
+
// await fetch('https://iam.gcdn.co/info/json')
|
|
128
|
+
await fetch(myinfoUrl)
|
|
128
129
|
.then(r => r.json())
|
|
129
130
|
.then(data => {
|
|
130
|
-
const country = data['Server Country code'].toLowerCase();
|
|
131
|
+
// const country = data['Server Country code'].toLowerCase();
|
|
132
|
+
const country = getCountryCodeFromClientHeaders(data.client_headers)
|
|
131
133
|
const server = serversList.find(s => s.country === country) || serversList[0];
|
|
132
134
|
if (!server) {
|
|
133
135
|
throw new Error('Failed to select a server');
|
|
@@ -181,3 +183,13 @@ function rankConnectionSpeed(dlSpeed: number): ConnectionSpeed {
|
|
|
181
183
|
}
|
|
182
184
|
return 0;
|
|
183
185
|
}
|
|
186
|
+
|
|
187
|
+
function getCountryCodeFromClientHeaders(clientHeaders: Record<string, string>): string {
|
|
188
|
+
if (clientHeaders && clientHeaders['country']) {
|
|
189
|
+
const m = clientHeaders['country'].match(/'code':\s*'([A-Za-z]{2})'/);
|
|
190
|
+
if (m) {
|
|
191
|
+
return m[1].toLowerCase();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return 'lu';
|
|
195
|
+
}
|
|
@@ -422,8 +422,8 @@ export class MediaControl extends UICorePlugin {
|
|
|
422
422
|
this.listenTo(this.core, Events.CORE_OPTIONS_CHANGE, this.configure)
|
|
423
423
|
this.listenTo(this.core, Events.CORE_RESIZE, this.playerResize)
|
|
424
424
|
|
|
425
|
-
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
426
|
-
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
425
|
+
// this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
426
|
+
// this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
427
427
|
|
|
428
428
|
// const has360 = this.core?.getPlugin('video_360');
|
|
429
429
|
|
|
@@ -468,6 +468,13 @@ export class MediaControl extends UICorePlugin {
|
|
|
468
468
|
Events.CONTAINER_DBLCLICK,
|
|
469
469
|
this.toggleFullscreen,
|
|
470
470
|
)
|
|
471
|
+
this.listenTo(
|
|
472
|
+
this.core.activeContainer,
|
|
473
|
+
Events.CONTAINER_CLICK,
|
|
474
|
+
() => {
|
|
475
|
+
this.clickaway(this.core.activeContainer.$el[0])
|
|
476
|
+
},
|
|
477
|
+
)
|
|
471
478
|
this.listenTo(
|
|
472
479
|
this.core.activeContainer,
|
|
473
480
|
Events.CONTAINER_TIMEUPDATE,
|
|
@@ -524,6 +531,10 @@ export class MediaControl extends UICorePlugin {
|
|
|
524
531
|
})
|
|
525
532
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_MOUSE_ENTER, this.show)
|
|
526
533
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_MOUSE_LEAVE, this.delayHide)
|
|
534
|
+
|
|
535
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_DESTROYED, () => {
|
|
536
|
+
this.clickaway(null)
|
|
537
|
+
})
|
|
527
538
|
}
|
|
528
539
|
|
|
529
540
|
/**
|
|
@@ -533,13 +544,17 @@ export class MediaControl extends UICorePlugin {
|
|
|
533
544
|
this.userDisabled = true // TODO distinguish between user and system (e.g., unplayable) disabled?
|
|
534
545
|
this.hide()
|
|
535
546
|
this.unbindKeyEvents()
|
|
536
|
-
this.$el.hide()
|
|
547
|
+
this.$el.hide()
|
|
537
548
|
}
|
|
538
549
|
|
|
539
550
|
/**
|
|
540
551
|
* Reenables the plugin disabled earlier with the {@link MediaControl.disable} method
|
|
541
552
|
*/
|
|
542
553
|
override enable() {
|
|
554
|
+
trace(`${T} enable`, {
|
|
555
|
+
chromeless: this.options.chromeless,
|
|
556
|
+
userDisabled: this.userDisabled,
|
|
557
|
+
})
|
|
543
558
|
if (this.options.chromeless) {
|
|
544
559
|
return
|
|
545
560
|
}
|
|
@@ -729,7 +744,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
729
744
|
|
|
730
745
|
try {
|
|
731
746
|
const skinWidth = this.container.$el.width() || size.width
|
|
732
|
-
|
|
733
747
|
if (skinWidth <= 370 || this.options.hideVolumeBar) {
|
|
734
748
|
this.$el.addClass('w370')
|
|
735
749
|
}
|
|
@@ -1032,10 +1046,16 @@ export class MediaControl extends UICorePlugin {
|
|
|
1032
1046
|
}
|
|
1033
1047
|
|
|
1034
1048
|
private setUserKeepVisible() {
|
|
1049
|
+
trace(`${T} setUserKeepVisible`, {
|
|
1050
|
+
userKeepVisible: this.userKeepVisible,
|
|
1051
|
+
})
|
|
1035
1052
|
this.userKeepVisible = true
|
|
1036
1053
|
}
|
|
1037
1054
|
|
|
1038
|
-
private resetUserKeepVisible() {
|
|
1055
|
+
private resetUserKeepVisible = () => {
|
|
1056
|
+
trace(`${T} resetUserKeepVisible`, {
|
|
1057
|
+
userKeepVisible: this.userKeepVisible,
|
|
1058
|
+
})
|
|
1039
1059
|
this.userKeepVisible = false
|
|
1040
1060
|
}
|
|
1041
1061
|
|
|
@@ -1044,6 +1064,11 @@ export class MediaControl extends UICorePlugin {
|
|
|
1044
1064
|
}
|
|
1045
1065
|
|
|
1046
1066
|
private show(event?: MouseEvent) {
|
|
1067
|
+
trace(`${T} show`, {
|
|
1068
|
+
disabled: this.disabled,
|
|
1069
|
+
disableControlPanel: this.options.disableControlPanel,
|
|
1070
|
+
event,
|
|
1071
|
+
})
|
|
1047
1072
|
if (this.disabled || this.options.disableControlPanel) {
|
|
1048
1073
|
return
|
|
1049
1074
|
}
|
|
@@ -1574,28 +1599,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
1574
1599
|
this.resetUserKeepVisible()
|
|
1575
1600
|
}
|
|
1576
1601
|
|
|
1577
|
-
// TODO manage by the ads plugin
|
|
1578
|
-
private onStartAd() {
|
|
1579
|
-
// this.advertisementPlaying = true
|
|
1580
|
-
this.disable()
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
// TODO manage by the ads plugin
|
|
1584
|
-
private onFinishAd() {
|
|
1585
|
-
// this.advertisementPlaying = false
|
|
1586
|
-
this.enable()
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
|
-
// TODO remove
|
|
1590
|
-
private hideControllAds() {
|
|
1591
|
-
if (
|
|
1592
|
-
this.container.advertisement &&
|
|
1593
|
-
this.container.advertisement.type !== 'idle'
|
|
1594
|
-
) {
|
|
1595
|
-
this.hide()
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
1602
|
private static getPageX(event: MouseEvent | TouchEvent): number {
|
|
1600
1603
|
return getPageX(event)
|
|
1601
1604
|
}
|
|
@@ -1653,6 +1656,8 @@ export class MediaControl extends UICorePlugin {
|
|
|
1653
1656
|
})
|
|
1654
1657
|
this.hide(this.options.hideMediaControlDelay || DEFAULT_HIDE_DELAY)
|
|
1655
1658
|
}
|
|
1659
|
+
|
|
1660
|
+
private clickaway = clickaway(this.resetUserKeepVisible)
|
|
1656
1661
|
}
|
|
1657
1662
|
|
|
1658
1663
|
MediaControl.extend = function (properties) {
|
|
@@ -1706,3 +1711,25 @@ function mergeElements(
|
|
|
1706
1711
|
return acc
|
|
1707
1712
|
}, a)
|
|
1708
1713
|
}
|
|
1714
|
+
|
|
1715
|
+
function clickaway(callback: () => void) {
|
|
1716
|
+
let handler = (event: MouseEvent | TouchEvent) => {}
|
|
1717
|
+
|
|
1718
|
+
return (node: HTMLElement | null) => {
|
|
1719
|
+
window.removeEventListener('click', handler)
|
|
1720
|
+
if (!node) {
|
|
1721
|
+
return
|
|
1722
|
+
}
|
|
1723
|
+
handler = (event: MouseEvent | TouchEvent) => {
|
|
1724
|
+
trace(`${T} clickaway`, {
|
|
1725
|
+
node,
|
|
1726
|
+
event,
|
|
1727
|
+
})
|
|
1728
|
+
if (!node.contains(event.target as Node)) {
|
|
1729
|
+
callback()
|
|
1730
|
+
window.removeEventListener('click', handler)
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
window.addEventListener('click', handler)
|
|
1734
|
+
}
|
|
1735
|
+
}
|