@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
|
@@ -2,7 +2,7 @@ import { reportError } from '@gcorevideo/utils';
|
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import URLHandler from './urlhandler.js';
|
|
4
4
|
import MergeVast from './xmlmerge.js';
|
|
5
|
-
import {
|
|
5
|
+
import { parseClipTime } from '../utils.js';
|
|
6
6
|
export default class LoaderXML {
|
|
7
7
|
url;
|
|
8
8
|
config = '';
|
|
@@ -91,7 +91,7 @@ export default class LoaderXML {
|
|
|
91
91
|
this.removeTag('Tracking', 'event="progress"');
|
|
92
92
|
}
|
|
93
93
|
if (linearSkipOffset && linearSkipOffset.length > 1) {
|
|
94
|
-
timeOffset =
|
|
94
|
+
timeOffset = parseClipTime(linearSkipOffset[1]);
|
|
95
95
|
this.config = this.config.replace(/<Linear skipoffset="(\d+:\d+:\d+)".*?>/g, '<Linear>');
|
|
96
96
|
}
|
|
97
97
|
return { skipEvents, progressEvents, timeOffset };
|
package/lib/testUtils.d.ts
CHANGED
|
@@ -94,9 +94,10 @@ export declare function createMockPlayback(name?: string): Events<string | symbo
|
|
|
94
94
|
switchAudioTrack: import("vitest").Mock<(...args: any[]) => any>;
|
|
95
95
|
trigger: <T extends string | symbol>(event: T, ...args: any[]) => boolean;
|
|
96
96
|
};
|
|
97
|
-
export declare function createMockContainer(playback?: any): Events<string | symbol, any> & {
|
|
97
|
+
export declare function createMockContainer(options?: Record<string, unknown>, playback?: any): Events<string | symbol, any> & {
|
|
98
98
|
el: any;
|
|
99
99
|
playback: any;
|
|
100
|
+
options: Record<string, unknown>;
|
|
100
101
|
$el: any;
|
|
101
102
|
getDuration: import("vitest").Mock<(...args: any[]) => any>;
|
|
102
103
|
getPlugin: import("vitest").Mock<(...args: any[]) => any>;
|
package/lib/testUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,MAAM;IAErC,SAAS,CAAC,OAAO,EAAE,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,GAAG;IAClB,SAAS,CAAC,WAAW,CAAC,EAAE,GAAG;gBAFjB,OAAO,EAAE,GAAG,EACb,IAAI,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,GAAG,YAAA;IAK7B,IAAI,IAAI,WAEP;IAED,OAAO;IAEP,IAAI;IAEJ,KAAK;IAEL,IAAI;IAEJ,OAAO;IAEP,IAAI;IAEJ,cAAc;IAEd,WAAW;IAIX,QAAQ;IAER,OAAO;IAEP,eAAe;IAIf,kBAAkB;IAIlB,cAAc;IAId,qBAAqB;IAIrB,IAAI;IAEJ,MAAM;IAEN,MAAM;IAEN,SAAS;IAET,eAAe;IAIf,WAAW;IAIX,QAAQ;IAIR,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAGtC;AAED,wBAAgB,cAAc,CAC5B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACrC,SAAS,GAAE,
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,MAAM,MAAM,eAAe,CAAA;AAElC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,MAAM;IAErC,SAAS,CAAC,OAAO,EAAE,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,GAAG;IAClB,SAAS,CAAC,WAAW,CAAC,EAAE,GAAG;gBAFjB,OAAO,EAAE,GAAG,EACb,IAAI,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,GAAG,YAAA;IAK7B,IAAI,IAAI,WAEP;IAED,OAAO;IAEP,IAAI;IAEJ,KAAK;IAEL,IAAI;IAEJ,OAAO;IAEP,IAAI;IAEJ,cAAc;IAEd,WAAW;IAIX,QAAQ;IAER,OAAO;IAEP,eAAe;IAIf,kBAAkB;IAIlB,cAAc;IAId,qBAAqB;IAIrB,IAAI;IAEJ,MAAM;IAEN,MAAM;IAEN,SAAS;IAET,eAAe;IAIf,WAAW;IAIX,QAAQ;IAIR,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAGtC;AAED,wBAAgB,cAAc,CAC5B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACrC,SAAS,GAAE,GAAkC;;;;;;;;;;;;;;;;EAqB9C;AAED,wBAAgB,gBAAgB;;;EAK/B;AAED,wBAAgB,mBAAmB;;;;;;EAKlC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC/C;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,QAAQ,GAAE,GAA0B;;;;;;;;;;;;;;;EAmB9G;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,gBAc/C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,OAY7C"}
|
package/lib/testUtils.js
CHANGED
|
@@ -60,7 +60,7 @@ export class _MockPlayback extends Events {
|
|
|
60
60
|
this.emit(event, ...args);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
export function createMockCore(options = {}, container = createMockContainer()) {
|
|
63
|
+
export function createMockCore(options = {}, container = createMockContainer(options)) {
|
|
64
64
|
const el = document.createElement('div');
|
|
65
65
|
const emitter = new Events();
|
|
66
66
|
return Object.assign(emitter, {
|
|
@@ -128,12 +128,13 @@ export function createMockPlayback(name = 'mock') {
|
|
|
128
128
|
trigger: emitter.emit,
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
export function createMockContainer(playback = createMockPlayback()) {
|
|
131
|
+
export function createMockContainer(options = {}, playback = createMockPlayback()) {
|
|
132
132
|
const el = playback.el;
|
|
133
133
|
const emitter = new Events();
|
|
134
134
|
return Object.assign(emitter, {
|
|
135
135
|
el,
|
|
136
136
|
playback,
|
|
137
|
+
options,
|
|
137
138
|
$el: $(el),
|
|
138
139
|
getDuration: vi.fn().mockReturnValue(0),
|
|
139
140
|
getPlugin: vi.fn(),
|
|
@@ -152,14 +153,11 @@ export function createMockMediaControl(core) {
|
|
|
152
153
|
mediaControl.$el.html(`<div class="media-control-left-panel" data-media-control></div>
|
|
153
154
|
<div class="media-control-right-panel" data-media-control></div>
|
|
154
155
|
<div class="media-control-center-panel" data-media-control></div>`);
|
|
155
|
-
const elements = {
|
|
156
|
-
gear: $(document.createElement('div')),
|
|
157
|
-
};
|
|
158
|
-
// @ts-ignore
|
|
159
|
-
mediaControl.getElement = vi.fn().mockImplementation((name) => elements[name]);
|
|
160
156
|
// @ts-ignore
|
|
161
157
|
mediaControl.putElement = vi.fn();
|
|
162
158
|
// @ts-ignore
|
|
159
|
+
mediaControl.mount = vi.fn();
|
|
160
|
+
// @ts-ignore
|
|
163
161
|
mediaControl.toggleElement = vi.fn();
|
|
164
162
|
return mediaControl;
|
|
165
163
|
}
|
package/package.json
CHANGED
package/src/index.plugins.ts
CHANGED
|
@@ -4,8 +4,9 @@ export * from "./plugins/audio-selector/AudioSelector.js";
|
|
|
4
4
|
export { AudioTracks as AudioSelector } from "./plugins/audio-selector/AudioSelector.js";
|
|
5
5
|
export * from "./plugins/big-mute-button/BigMuteButton.js";
|
|
6
6
|
export * from "./plugins/bottom-gear/BottomGear.js";
|
|
7
|
-
export * from "./plugins/clappr-nerd-stats/ClapprNerdStats.js";
|
|
8
7
|
export * from "./plugins/clappr-stats/ClapprStats.js";
|
|
8
|
+
export * from "./plugins/clappr-nerd-stats/NerdStats.js";
|
|
9
|
+
export { NerdStats as ClapprNerdStats } from "./plugins/clappr-nerd-stats/NerdStats.js";
|
|
9
10
|
export * from "./plugins/click-to-pause/ClickToPause.js";
|
|
10
11
|
export * from "./plugins/clips/Clips.js";
|
|
11
12
|
export * from "./plugins/context-menu/ContextMenu.js";
|
|
@@ -543,15 +543,12 @@ export default class DashPlayback extends BasePlayback {
|
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
override _onProgress() {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
546
|
+
const buffer =
|
|
547
|
+
// @ts-expect-error
|
|
548
|
+
this._dash.getDashMetrics().getCurrentBufferLevel('video') ||
|
|
549
|
+
// @ts-expect-error
|
|
550
|
+
this._dash.getDashMetrics().getCurrentBufferLevel('audio')
|
|
551
551
|
|
|
552
|
-
if (!buffer) {
|
|
553
|
-
buffer = this._dash.getDashMetrics().getCurrentBufferLevel('audio')
|
|
554
|
-
}
|
|
555
552
|
const progress = {
|
|
556
553
|
start: this.getCurrentTime(),
|
|
557
554
|
current: this.getCurrentTime() + buffer,
|
package/src/playback.types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Playback time in seconds since the beginning of the stream
|
|
2
|
+
* Playback time position in seconds since the beginning of the stream.
|
|
3
|
+
* For the live streams this is limited to the length of a segment. When DVR is enabled, this refers to the
|
|
3
4
|
* @public
|
|
4
5
|
*/
|
|
5
6
|
export type TimeValue = number
|
|
@@ -10,20 +11,33 @@ export type TimeValue = number
|
|
|
10
11
|
*/
|
|
11
12
|
export interface TimePosition {
|
|
12
13
|
/**
|
|
13
|
-
* Current playback time, 0..duration
|
|
14
|
+
* Current playback time, 0..duration
|
|
14
15
|
*/
|
|
15
16
|
current: TimeValue
|
|
16
17
|
/**
|
|
17
|
-
* Total duration of the media
|
|
18
|
+
* Total duration of the media content (or DVR window size or segment duration for live streams)
|
|
18
19
|
*/
|
|
19
20
|
total: TimeValue
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Time progress information indicated by Clappr CONTAINER_PROGRESS and PLAYBACK_PROGRESS events.
|
|
24
25
|
* @beta
|
|
25
26
|
*/
|
|
26
|
-
export type TimeProgress =
|
|
27
|
+
export type TimeProgress = {
|
|
28
|
+
/**
|
|
29
|
+
* Current playback time
|
|
30
|
+
*/
|
|
31
|
+
start: TimeValue
|
|
32
|
+
/**
|
|
33
|
+
* Current buffer length beginning from the start (=current) time
|
|
34
|
+
*/
|
|
35
|
+
current: TimeValue
|
|
36
|
+
/**
|
|
37
|
+
* Total duration of the media content
|
|
38
|
+
*/
|
|
39
|
+
total: TimeValue
|
|
40
|
+
}
|
|
27
41
|
|
|
28
42
|
/**
|
|
29
43
|
* For the plugin development
|
|
@@ -34,20 +48,21 @@ export type TimeUpdate = TimePosition & {
|
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
/**
|
|
37
|
-
* A level of quality within a media source.
|
|
51
|
+
* A level of quality within a media source/representation.
|
|
38
52
|
* @public
|
|
39
53
|
*/
|
|
40
54
|
export interface QualityLevel {
|
|
41
55
|
/**
|
|
42
56
|
* Zero-based index of the quality level.
|
|
57
|
+
* Quality levels go from low to high
|
|
43
58
|
*/
|
|
44
59
|
level: number
|
|
45
60
|
/**
|
|
46
|
-
* Width of the video, pixels.
|
|
61
|
+
* Width of the video frame, pixels.
|
|
47
62
|
*/
|
|
48
63
|
width: number
|
|
49
64
|
/**
|
|
50
|
-
* Height of the video, pixels.
|
|
65
|
+
* Height of the video frame, pixels.
|
|
51
66
|
*/
|
|
52
67
|
height: number
|
|
53
68
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UICorePlugin, Events, template, Core, Container } from '@clappr/core'
|
|
2
2
|
import { reportError, trace } from '@gcorevideo/utils'
|
|
3
3
|
import Mousetrap from 'mousetrap'
|
|
4
|
+
import assert from 'assert'
|
|
4
5
|
|
|
5
6
|
import { CLAPPR_VERSION } from '../../build.js'
|
|
6
7
|
import {
|
|
@@ -25,7 +26,6 @@ import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs'
|
|
|
25
26
|
import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs'
|
|
26
27
|
import statsIcon from '../../../assets/icons/new/stats.svg'
|
|
27
28
|
import { BottomGear, GearEvents } from '../bottom-gear/BottomGear.js'
|
|
28
|
-
import assert from 'assert'
|
|
29
29
|
|
|
30
30
|
const qualityClasses = [
|
|
31
31
|
'speedtest-quality-value-1',
|
|
@@ -113,7 +113,7 @@ type Metrics = BaseMetrics & {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const T = 'plugins.
|
|
116
|
+
const T = 'plugins.nerd_stats'
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* `PLUGIN` that displays useful network-related statistics.
|
|
@@ -131,7 +131,7 @@ const T = 'plugins.clappr_nerd_stats'
|
|
|
131
131
|
* When clicked, it shows an overlay window with the information about the network speed, latency, etc,
|
|
132
132
|
* and recommended quality level.
|
|
133
133
|
*/
|
|
134
|
-
export class
|
|
134
|
+
export class NerdStats extends UICorePlugin {
|
|
135
135
|
private container: Container | null = null
|
|
136
136
|
|
|
137
137
|
private customMetrics: CustomMetrics = {
|
|
@@ -234,32 +234,27 @@ export class ClapprNerdStats extends UICorePlugin {
|
|
|
234
234
|
|
|
235
235
|
this.container = this.core.activeContainer
|
|
236
236
|
const clapprStats = this.container?.getPlugin('clappr_stats')
|
|
237
|
+
assert(
|
|
238
|
+
clapprStats,
|
|
239
|
+
'clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
|
|
240
|
+
'For more info, visit: https://github.com/clappr/clappr-stats.',
|
|
241
|
+
)
|
|
242
|
+
Mousetrap.bind(this.shortcut, this.toggle)
|
|
243
|
+
this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize)
|
|
244
|
+
this.listenTo(clapprStats, ClapprStatsEvents.REPORT, this.updateMetrics)
|
|
245
|
+
this.updateMetrics(clapprStats.exportMetrics())
|
|
246
|
+
this.render()
|
|
247
|
+
}
|
|
237
248
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
}
|
|
249
|
+
/**
|
|
250
|
+
* @internal
|
|
251
|
+
*/
|
|
252
|
+
override destroy() {
|
|
253
|
+
Mousetrap.unbind(this.shortcut)
|
|
254
|
+
return super.destroy()
|
|
260
255
|
}
|
|
261
256
|
|
|
262
|
-
private toggle() {
|
|
257
|
+
private toggle = () => {
|
|
263
258
|
if (this.showing) {
|
|
264
259
|
this.hide()
|
|
265
260
|
} else {
|
|
@@ -338,7 +333,7 @@ export class ClapprNerdStats extends UICorePlugin {
|
|
|
338
333
|
const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop()
|
|
339
334
|
|
|
340
335
|
this.$el.html(
|
|
341
|
-
|
|
336
|
+
NerdStats.template({
|
|
342
337
|
metrics: Formatter.format(this.metrics),
|
|
343
338
|
iconPosition: this.iconPosition,
|
|
344
339
|
}),
|
|
@@ -383,10 +378,10 @@ export class ClapprNerdStats extends UICorePlugin {
|
|
|
383
378
|
private addToBottomGear() {
|
|
384
379
|
trace(`${T} addToBottomGear`)
|
|
385
380
|
const gear = this.core.getPlugin('bottom_gear') as BottomGear
|
|
386
|
-
|
|
387
|
-
.addItem('
|
|
381
|
+
gear
|
|
382
|
+
.addItem('nerd_stats')
|
|
388
383
|
.html(
|
|
389
|
-
|
|
384
|
+
NerdStats.buttonTemplate({
|
|
390
385
|
icon: statsIcon,
|
|
391
386
|
i18n: this.core.i18n,
|
|
392
387
|
}),
|