@gcorevideo/player 2.28.16 → 2.28.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/dist/core.js +1 -1
- package/dist/index.css +273 -273
- package/dist/index.embed.js +64 -39
- package/dist/index.js +81 -49
- 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 +0 -3
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +34 -20
- 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 +39 -26
- package/tsconfig.tsbuildinfo +1 -1
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,14 @@ export class MediaControl extends UICorePlugin {
|
|
|
468
468
|
Events.CONTAINER_DBLCLICK,
|
|
469
469
|
this.toggleFullscreen,
|
|
470
470
|
)
|
|
471
|
+
const clk = clickaway(() => {
|
|
472
|
+
this.resetUserKeepVisible()
|
|
473
|
+
}, this.core.activeContainer.$el[0])
|
|
474
|
+
this.listenTo(
|
|
475
|
+
this.core.activeContainer,
|
|
476
|
+
Events.CONTAINER_CLICK,
|
|
477
|
+
clk,
|
|
478
|
+
)
|
|
471
479
|
this.listenTo(
|
|
472
480
|
this.core.activeContainer,
|
|
473
481
|
Events.CONTAINER_TIMEUPDATE,
|
|
@@ -530,16 +538,21 @@ export class MediaControl extends UICorePlugin {
|
|
|
530
538
|
* Hides the media control UI
|
|
531
539
|
*/
|
|
532
540
|
override disable() {
|
|
541
|
+
trace(`${T} disable`)
|
|
533
542
|
this.userDisabled = true // TODO distinguish between user and system (e.g., unplayable) disabled?
|
|
534
543
|
this.hide()
|
|
535
544
|
this.unbindKeyEvents()
|
|
536
|
-
this.$el.hide()
|
|
545
|
+
this.$el.hide()
|
|
537
546
|
}
|
|
538
547
|
|
|
539
548
|
/**
|
|
540
549
|
* Reenables the plugin disabled earlier with the {@link MediaControl.disable} method
|
|
541
550
|
*/
|
|
542
551
|
override enable() {
|
|
552
|
+
trace(`${T} enable`, {
|
|
553
|
+
chromeless: this.options.chromeless,
|
|
554
|
+
userDisabled: this.userDisabled,
|
|
555
|
+
})
|
|
543
556
|
if (this.options.chromeless) {
|
|
544
557
|
return
|
|
545
558
|
}
|
|
@@ -729,7 +742,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
729
742
|
|
|
730
743
|
try {
|
|
731
744
|
const skinWidth = this.container.$el.width() || size.width
|
|
732
|
-
|
|
733
745
|
if (skinWidth <= 370 || this.options.hideVolumeBar) {
|
|
734
746
|
this.$el.addClass('w370')
|
|
735
747
|
}
|
|
@@ -1032,10 +1044,16 @@ export class MediaControl extends UICorePlugin {
|
|
|
1032
1044
|
}
|
|
1033
1045
|
|
|
1034
1046
|
private setUserKeepVisible() {
|
|
1047
|
+
trace(`${T} setUserKeepVisible`, {
|
|
1048
|
+
userKeepVisible: this.userKeepVisible,
|
|
1049
|
+
})
|
|
1035
1050
|
this.userKeepVisible = true
|
|
1036
1051
|
}
|
|
1037
1052
|
|
|
1038
1053
|
private resetUserKeepVisible() {
|
|
1054
|
+
trace(`${T} resetUserKeepVisible`, {
|
|
1055
|
+
userKeepVisible: this.userKeepVisible,
|
|
1056
|
+
})
|
|
1039
1057
|
this.userKeepVisible = false
|
|
1040
1058
|
}
|
|
1041
1059
|
|
|
@@ -1044,6 +1062,11 @@ export class MediaControl extends UICorePlugin {
|
|
|
1044
1062
|
}
|
|
1045
1063
|
|
|
1046
1064
|
private show(event?: MouseEvent) {
|
|
1065
|
+
trace(`${T} show`, {
|
|
1066
|
+
disabled: this.disabled,
|
|
1067
|
+
disableControlPanel: this.options.disableControlPanel,
|
|
1068
|
+
event,
|
|
1069
|
+
})
|
|
1047
1070
|
if (this.disabled || this.options.disableControlPanel) {
|
|
1048
1071
|
return
|
|
1049
1072
|
}
|
|
@@ -1574,28 +1597,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
1574
1597
|
this.resetUserKeepVisible()
|
|
1575
1598
|
}
|
|
1576
1599
|
|
|
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
1600
|
private static getPageX(event: MouseEvent | TouchEvent): number {
|
|
1600
1601
|
return getPageX(event)
|
|
1601
1602
|
}
|
|
@@ -1706,3 +1707,15 @@ function mergeElements(
|
|
|
1706
1707
|
return acc
|
|
1707
1708
|
}, a)
|
|
1708
1709
|
}
|
|
1710
|
+
|
|
1711
|
+
function clickaway(callback: () => void, element: Node) {
|
|
1712
|
+
const handler = (event: MouseEvent | TouchEvent) => {
|
|
1713
|
+
if (!element.contains(event.target as Node)) {
|
|
1714
|
+
callback()
|
|
1715
|
+
window.removeEventListener('click', handler)
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return () => {
|
|
1719
|
+
window.addEventListener('click', handler)
|
|
1720
|
+
}
|
|
1721
|
+
}
|