@gcorevideo/player 2.19.14 → 2.20.1
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/level-selector/list.ejs +2 -2
- package/dist/core.js +2 -2
- package/dist/index.css +780 -780
- package/dist/index.js +1720 -1473
- package/dist/player.d.ts +425 -94
- package/dist/plugins/index.css +1466 -1466
- package/dist/plugins/index.js +1501 -1252
- package/docs/api/player.bottomgear.getelement.md +56 -0
- package/docs/api/player.bottomgear.md +51 -0
- package/docs/api/player.bottomgear.setcontent.md +56 -0
- package/docs/api/player.clapprnerdstats.md +12 -259
- package/docs/api/player.dvrcontrols.md +5 -1
- package/docs/api/player.errorscreen.attributes.md +3 -0
- package/docs/api/player.errorscreen.bindevents.md +3 -0
- package/docs/api/player.errorscreen.container.md +3 -0
- package/docs/api/player.errorscreen.hide.md +3 -0
- package/docs/api/player.errorscreen.md +27 -0
- package/docs/api/player.errorscreen.name.md +3 -0
- package/docs/api/player.errorscreen.render.md +3 -0
- package/docs/api/player.errorscreen.show.md +3 -0
- package/docs/api/player.errorscreen.supportedversion.md +3 -0
- package/docs/api/player.errorscreen.template.md +3 -0
- package/docs/api/player.errorscreen.unbindevents.md +3 -0
- package/docs/api/player.gearevents.md +49 -0
- package/docs/api/{player.sourcecontroller.name.md → player.gearitemelement.md} +5 -3
- package/docs/api/{player.playbackrate.template.md → player.initeventdata.event.md} +3 -3
- package/docs/api/{player.playbackrate.updateplaybackrate.md → player.initeventdata.md} +15 -11
- package/docs/api/player.levelselector.md +9 -1
- package/docs/api/player.md +124 -4
- package/docs/api/{player.clapprnerdstats.render.md → player.mediacontrol.getrightpanel.md} +8 -4
- package/docs/api/player.mediacontrol.md +14 -0
- package/docs/api/player.mediacontrolelement.md +1 -1
- package/docs/api/player.pictureinpicture.md +9 -197
- package/docs/api/player.playbackrate.md +10 -314
- package/docs/api/player.sourcecontroller.md +0 -90
- package/docs/api/player.spinnerevents.md +49 -0
- package/docs/api/player.spinnerthreebounce._constructor_.md +3 -0
- package/docs/api/player.spinnerthreebounce.hide.md +5 -0
- package/docs/api/player.spinnerthreebounce.md +14 -95
- package/docs/api/player.spinnerthreebounce.show.md +6 -37
- package/docs/api/{player.playbackrate.onplay.md → player.stalleventdata.count.md} +5 -7
- package/docs/api/{player.playbackrate.name.md → player.stalleventdata.event.md} +3 -3
- package/docs/api/player.stalleventdata.md +112 -0
- package/docs/api/player.stalleventdata.time.md +13 -0
- package/docs/api/player.stalleventdata.total_ms.md +13 -0
- package/docs/api/{player.pluginsettings.md → player.starteventdata.event.md} +3 -5
- package/docs/api/{player.playbackrate.onrateselect.md → player.starteventdata.md} +15 -11
- package/docs/api/player.subtitles.hide.md +5 -0
- package/docs/api/player.subtitles.md +23 -275
- package/docs/api/player.subtitles.show.md +5 -0
- package/docs/api/{player.statistics._constructor_.md → player.telemetry._constructor_.md} +6 -3
- package/docs/api/player.telemetry.md +146 -0
- package/docs/api/{player.volumefade.name.md → player.telemetry.name.md} +4 -2
- package/docs/api/{player.sourcecontroller.supportedversion.md → player.telemetry.supportedversion.md} +4 -2
- package/docs/api/player.telemetryevent.md +89 -0
- package/docs/api/player.telemetryeventdata.md +15 -0
- package/docs/api/player.telemetrypluginsettings.md +57 -0
- package/docs/api/player.telemetrypluginsettings.send.md +13 -0
- package/docs/api/player.telemetryrecord.md +17 -0
- package/docs/api/player.volumefade.md +0 -93
- package/docs/api/{player.pictureinpicture.name.md → player.watcheventdata.event.md} +3 -3
- package/docs/api/{player.playbackrate.setselectedrate.md → player.watcheventdata.md} +15 -11
- package/lib/index.plugins.d.ts +2 -2
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +2 -2
- package/lib/playback/hls-playback/HlsPlayback.js +1 -1
- package/lib/plugins/bottom-gear/BottomGear.d.ts +20 -1
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +28 -7
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +38 -5
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +67 -21
- package/lib/plugins/dvr-controls/DvrControls.d.ts +5 -2
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DvrControls.js +5 -2
- package/lib/plugins/error-screen/ErrorScreen.d.ts +5 -0
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
- package/lib/plugins/error-screen/ErrorScreen.js +5 -0
- package/lib/plugins/index.d.ts +2 -3
- package/lib/plugins/index.d.ts.map +1 -1
- package/lib/plugins/index.js +2 -3
- package/lib/plugins/level-selector/LevelSelector.d.ts +10 -3
- package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
- package/lib/plugins/level-selector/LevelSelector.js +20 -19
- package/lib/plugins/media-control/MediaControl.d.ts +6 -2
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +40 -39
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +32 -4
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
- package/lib/plugins/picture-in-picture/PictureInPicture.js +30 -2
- package/lib/plugins/playback-rate/PlaybackRate.d.ts +47 -14
- package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
- package/lib/plugins/playback-rate/PlaybackRate.js +38 -9
- package/lib/plugins/source-controller/SourceController.d.ts +9 -0
- package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
- package/lib/plugins/source-controller/SourceController.js +11 -1
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +35 -1
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +46 -23
- package/lib/plugins/statistics/Statistics.d.ts +38 -3
- package/lib/plugins/statistics/Statistics.d.ts.map +1 -1
- package/lib/plugins/statistics/Statistics.js +51 -9
- package/lib/plugins/subtitles/Subtitles.d.ts +65 -16
- package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -1
- package/lib/plugins/subtitles/Subtitles.js +131 -109
- package/lib/plugins/telemetry/Telemetry.d.ts +135 -0
- package/lib/plugins/telemetry/Telemetry.d.ts.map +1 -0
- package/lib/plugins/telemetry/Telemetry.js +180 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts +7 -1
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -1
- package/lib/plugins/volume-fade/VolumeFade.js +8 -1
- package/package.json +1 -1
- package/src/index.plugins.ts +2 -2
- package/src/playback/hls-playback/HlsPlayback.ts +1 -1
- package/src/plugins/bottom-gear/BottomGear.ts +26 -4
- package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +240 -173
- package/src/plugins/dvr-controls/DvrControls.ts +5 -2
- package/src/plugins/error-screen/ErrorScreen.ts +5 -0
- package/src/plugins/index.ts +2 -3
- package/src/plugins/level-selector/LevelSelector.ts +22 -19
- package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +47 -26
- package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +18 -18
- package/src/plugins/media-control/MediaControl.ts +43 -41
- package/src/plugins/picture-in-picture/PictureInPicture.ts +35 -7
- package/src/plugins/playback-rate/PlaybackRate.ts +53 -24
- package/src/plugins/source-controller/SourceController.ts +11 -1
- package/src/plugins/source-controller/__tests__/SourceController.test.ts +1 -1
- package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +46 -22
- package/src/plugins/subtitles/Subtitles.ts +146 -155
- package/src/plugins/telemetry/Telemetry.ts +299 -0
- package/src/plugins/volume-fade/VolumeFade.ts +9 -2
- package/temp/player.api.json +3384 -4872
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.clapprnerdstats.attributes.md +0 -17
- package/docs/api/player.clapprnerdstats.bindevents.md +0 -18
- package/docs/api/player.clapprnerdstats.events.md +0 -18
- package/docs/api/player.clapprnerdstats.name.md +0 -14
- package/docs/api/player.clapprnerdstats.playerheight.md +0 -14
- package/docs/api/player.clapprnerdstats.playerwidth.md +0 -14
- package/docs/api/player.clapprnerdstats.statsboxelem.md +0 -14
- package/docs/api/player.clapprnerdstats.statsboxwidththreshold.md +0 -14
- package/docs/api/player.clapprnerdstats.supportedversion.md +0 -16
- package/docs/api/player.clapprnerdstats.template.md +0 -14
- package/docs/api/player.pictureinpicture.bindevents.md +0 -15
- package/docs/api/player.pictureinpicture.events.md +0 -13
- package/docs/api/player.pictureinpicture.exitpictureinpicture.md +0 -15
- package/docs/api/player.pictureinpicture.render.md +0 -15
- package/docs/api/player.pictureinpicture.requestpictureinpicture.md +0 -15
- package/docs/api/player.pictureinpicture.supportedversion.md +0 -13
- package/docs/api/player.pictureinpicture.togglepictureinpicture.md +0 -15
- package/docs/api/player.pictureinpicture.version.md +0 -11
- package/docs/api/player.pictureinpicture.videoelement.md +0 -11
- package/docs/api/player.playbackrate.attributes.md +0 -14
- package/docs/api/player.playbackrate.bindevents.md +0 -15
- package/docs/api/player.playbackrate.events.md +0 -15
- package/docs/api/player.playbackrate.gettitle.md +0 -15
- package/docs/api/player.playbackrate.goback.md +0 -15
- package/docs/api/player.playbackrate.highlightcurrentrate.md +0 -15
- package/docs/api/player.playbackrate.onfinishad.md +0 -15
- package/docs/api/player.playbackrate.onshowmenu.md +0 -15
- package/docs/api/player.playbackrate.onstartad.md +0 -15
- package/docs/api/player.playbackrate.onstop.md +0 -15
- package/docs/api/player.playbackrate.reload.md +0 -15
- package/docs/api/player.playbackrate.render.md +0 -15
- package/docs/api/player.playbackrate.supportedversion.md +0 -13
- package/docs/api/player.playbackrate.unbindevents.md +0 -15
- package/docs/api/player.sourcecontroller.version.md +0 -14
- package/docs/api/player.spinnerthreebounce.attributes.md +0 -14
- package/docs/api/player.spinnerthreebounce.name.md +0 -11
- package/docs/api/player.spinnerthreebounce.render.md +0 -15
- package/docs/api/player.spinnerthreebounce.supportedversion.md +0 -13
- package/docs/api/player.statistics.bindevents.md +0 -15
- package/docs/api/player.statistics.md +0 -141
- package/docs/api/player.statistics.name.md +0 -11
- package/docs/api/player.statistics.supportedversion.md +0 -13
- package/docs/api/player.subtitles.attributes.md +0 -14
- package/docs/api/player.subtitles.bindevents.md +0 -15
- package/docs/api/player.subtitles.buttonelement.md +0 -15
- package/docs/api/player.subtitles.events.md +0 -14
- package/docs/api/player.subtitles.levelelement.md +0 -51
- package/docs/api/player.subtitles.name.md +0 -11
- package/docs/api/player.subtitles.preselectedlanguage.md +0 -11
- package/docs/api/player.subtitles.reload.md +0 -15
- package/docs/api/player.subtitles.render.md +0 -15
- package/docs/api/player.subtitles.selectsubtitles.md +0 -15
- package/docs/api/player.subtitles.startlevelswitch.md +0 -15
- package/docs/api/player.subtitles.stoplevelswitch.md +0 -15
- package/docs/api/player.subtitles.supportedversion.md +0 -13
- package/docs/api/player.subtitles.template.md +0 -11
- package/docs/api/player.subtitles.templatestring.md +0 -11
- package/docs/api/player.subtitles.unbindevents.md +0 -15
- package/docs/api/player.subtitles.version.md +0 -11
- package/docs/api/player.volumefade.bindevents.md +0 -18
- package/docs/api/player.volumefade.unbindevents.md +0 -18
- package/src/plugins/statistics/Statistics.ts +0 -207
- /package/src/plugins/{statistics → telemetry}/Statistics copy.xts +0 -0
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
// Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
2
2
|
// Use of this source code is governed by a BSD-style
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
|
-
import { Events, UIContainerPlugin, template } from '@clappr/core';
|
|
4
|
+
import { Events as ClapprEvents, UIContainerPlugin, template } from '@clappr/core';
|
|
5
5
|
import { PlaybackErrorCode } from '../../playback.types.js';
|
|
6
6
|
import { trace } from '@gcorevideo/utils';
|
|
7
7
|
import spinnerHTML from '../../../assets/spinner-three-bounce/spinner.ejs';
|
|
8
8
|
import '../../../assets/spinner-three-bounce/spinner.scss';
|
|
9
9
|
import { CLAPPR_VERSION } from '../../build.js';
|
|
10
10
|
const T = 'plugins.spinner';
|
|
11
|
+
/**
|
|
12
|
+
* Custom events emitted by the plugin
|
|
13
|
+
*/
|
|
14
|
+
export var SpinnerEvents;
|
|
15
|
+
(function (SpinnerEvents) {
|
|
16
|
+
/**
|
|
17
|
+
* Emitted at the end of the spinner animation cycle to facilitate smooth UI updates,
|
|
18
|
+
* e.g. {@link SourceController} listens to this event to reload the source when the spinner is hidden
|
|
19
|
+
*/
|
|
20
|
+
SpinnerEvents["SYNC"] = "plugins:spinner:sync";
|
|
21
|
+
})(SpinnerEvents || (SpinnerEvents = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Shows a pending operation indicator when playback is buffering or in other appropriate cases
|
|
24
|
+
* @beta
|
|
25
|
+
* @remarks
|
|
26
|
+
* The plugin emits
|
|
27
|
+
*/
|
|
11
28
|
export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
12
32
|
get name() {
|
|
13
33
|
return 'spinner';
|
|
14
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
15
38
|
get supportedVersion() {
|
|
16
39
|
return { min: CLAPPR_VERSION };
|
|
17
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
18
44
|
get attributes() {
|
|
19
45
|
return {
|
|
20
46
|
'data-spinner': '',
|
|
@@ -27,13 +53,13 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
27
53
|
hasBuffering = false;
|
|
28
54
|
constructor(container) {
|
|
29
55
|
super(container);
|
|
30
|
-
this.listenTo(this.container,
|
|
31
|
-
this.listenTo(this.container,
|
|
32
|
-
this.listenTo(this.container,
|
|
33
|
-
this.listenTo(this.container,
|
|
34
|
-
this.listenTo(this.container,
|
|
35
|
-
this.listenTo(this.container,
|
|
36
|
-
this.listenTo(this.container,
|
|
56
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_STATE_BUFFERING, this.onBuffering);
|
|
57
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_STATE_BUFFERFULL, this.onBufferFull);
|
|
58
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_PLAY, this.onPlay);
|
|
59
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_STOP, this.onStop);
|
|
60
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_ENDED, this.onStop);
|
|
61
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_ERROR, this.onError);
|
|
62
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_READY, this.render);
|
|
37
63
|
}
|
|
38
64
|
onBuffering() {
|
|
39
65
|
this.hasBuffering = true;
|
|
@@ -73,21 +99,15 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
73
99
|
this.hide();
|
|
74
100
|
}
|
|
75
101
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (this.showTimeout !== null) {
|
|
82
|
-
clearTimeout(this.showTimeout);
|
|
83
|
-
this.showTimeout = null;
|
|
84
|
-
}
|
|
85
|
-
this.$el.show();
|
|
86
|
-
}
|
|
87
|
-
else if (this.showTimeout === null) {
|
|
88
|
-
this.showTimeout = setTimeout(() => this.$el.show(), 300);
|
|
89
|
-
}
|
|
102
|
+
/**
|
|
103
|
+
* Shows the spinner
|
|
104
|
+
*/
|
|
105
|
+
show() {
|
|
106
|
+
this.showTimeout = setTimeout(() => this.$el.show(), 300);
|
|
90
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Hides the spinner
|
|
110
|
+
*/
|
|
91
111
|
hide() {
|
|
92
112
|
if (this.showTimeout !== null) {
|
|
93
113
|
clearTimeout(this.showTimeout);
|
|
@@ -95,6 +115,9 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
95
115
|
}
|
|
96
116
|
this.$el.hide();
|
|
97
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
98
121
|
render() {
|
|
99
122
|
const showOnStart = this.options.spinner?.showOnStart;
|
|
100
123
|
trace(`${T} render`, {
|
|
@@ -103,7 +126,7 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
103
126
|
});
|
|
104
127
|
this.$el.html(this.template());
|
|
105
128
|
this.el.firstElementChild?.addEventListener('animationiteration', () => {
|
|
106
|
-
this.trigger(
|
|
129
|
+
this.trigger(SpinnerEvents.SYNC);
|
|
107
130
|
});
|
|
108
131
|
this.container.$el.append(this.$el[0]);
|
|
109
132
|
if (showOnStart || this.container.buffering) {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Container, ContainerPlugin } from '@clappr/core';
|
|
2
|
-
import type { PlaybackType } from '
|
|
2
|
+
import type { PlaybackType } from '../../types';
|
|
3
3
|
type StatisticsEventData = Record<string, string | number | boolean>;
|
|
4
4
|
type StatisticsRecord = {
|
|
5
5
|
event: StatisticsEvent;
|
|
6
6
|
type: PlaybackType;
|
|
7
7
|
} & StatisticsEventData;
|
|
8
|
+
/**
|
|
9
|
+
* Plugin settings
|
|
10
|
+
*/
|
|
8
11
|
export type PluginSettings = {
|
|
9
12
|
/**
|
|
10
13
|
* Sends the statistics record to the storage.
|
|
@@ -14,8 +17,37 @@ export type PluginSettings = {
|
|
|
14
17
|
send: (data: StatisticsRecord) => void;
|
|
15
18
|
};
|
|
16
19
|
type StatisticsEvent = 'init' | 'start' | 'watch' | 'heatmap';
|
|
20
|
+
/**
|
|
21
|
+
* Collects and reports the performance statistics.
|
|
22
|
+
* @beta
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { Statistics } from '@gcorevideo/player'
|
|
26
|
+
*
|
|
27
|
+
* Player.registerPlugin(Statistics)
|
|
28
|
+
*
|
|
29
|
+
* const player = new Player({
|
|
30
|
+
* statistics: {
|
|
31
|
+
* send: (data) => {
|
|
32
|
+
* fetch('/stats', {
|
|
33
|
+
* method: 'POST',
|
|
34
|
+
* body: JSON.stringify(data),
|
|
35
|
+
* headers: { 'content-type': 'application/json' },
|
|
36
|
+
* })
|
|
37
|
+
* }
|
|
38
|
+
* },
|
|
39
|
+
* ...
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
17
43
|
export declare class Statistics extends ContainerPlugin {
|
|
44
|
+
/**
|
|
45
|
+
* The name of the plugin.
|
|
46
|
+
*/
|
|
18
47
|
get name(): string;
|
|
48
|
+
/**
|
|
49
|
+
* The supported version of the plugin.
|
|
50
|
+
*/
|
|
19
51
|
get supportedVersion(): {
|
|
20
52
|
min: string;
|
|
21
53
|
};
|
|
@@ -35,13 +67,16 @@ export declare class Statistics extends ContainerPlugin {
|
|
|
35
67
|
*/
|
|
36
68
|
private bufAccDuration;
|
|
37
69
|
constructor(container: Container);
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
38
73
|
bindEvents(): void;
|
|
39
74
|
private startLevelSwitch;
|
|
40
|
-
private
|
|
75
|
+
private endLevelSwitch;
|
|
41
76
|
private onBuffering;
|
|
42
77
|
private onBufferFull;
|
|
43
78
|
private onReady;
|
|
44
|
-
private
|
|
79
|
+
private sendInit;
|
|
45
80
|
private sendMessage;
|
|
46
81
|
private send;
|
|
47
82
|
private sendHeatmap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Statistics.d.ts","sourceRoot":"","sources":["../../../src/plugins/statistics/Statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Statistics.d.ts","sourceRoot":"","sources":["../../../src/plugins/statistics/Statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAA;AAK3E,OAAO,KAAK,EA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AAO;CAOhB"}
|
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
// An example implementation of client side performancestatistics
|
|
2
2
|
import { ContainerPlugin, Events, Playback } from '@clappr/core';
|
|
3
|
-
import { reportError } from '@gcorevideo/utils';
|
|
3
|
+
import { reportError, trace } from '@gcorevideo/utils';
|
|
4
4
|
import assert from 'assert';
|
|
5
5
|
import { CLAPPR_VERSION } from '../../build.js';
|
|
6
|
-
const CUSTOM_EVENTS_CONTAINER_START = 'container:start'
|
|
6
|
+
// const CUSTOM_EVENTS_CONTAINER_START = 'container:start'
|
|
7
7
|
const WATCH_CUTOFF = 5;
|
|
8
8
|
const HEATMAP_INTERVAL = 10;
|
|
9
|
-
|
|
9
|
+
const T = 'plugins.statistics';
|
|
10
|
+
/**
|
|
11
|
+
* Collects and reports the performance statistics.
|
|
12
|
+
* @beta
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Statistics } from '@gcorevideo/player'
|
|
16
|
+
*
|
|
17
|
+
* Player.registerPlugin(Statistics)
|
|
18
|
+
*
|
|
19
|
+
* const player = new Player({
|
|
20
|
+
* statistics: {
|
|
21
|
+
* send: (data) => {
|
|
22
|
+
* fetch('/stats', {
|
|
23
|
+
* method: 'POST',
|
|
24
|
+
* body: JSON.stringify(data),
|
|
25
|
+
* headers: { 'content-type': 'application/json' },
|
|
26
|
+
* })
|
|
27
|
+
* }
|
|
28
|
+
* },
|
|
29
|
+
* ...
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
10
33
|
export class Statistics extends ContainerPlugin {
|
|
34
|
+
/**
|
|
35
|
+
* The name of the plugin.
|
|
36
|
+
*/
|
|
11
37
|
get name() {
|
|
12
|
-
return '
|
|
38
|
+
return 'statistics';
|
|
13
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The supported version of the plugin.
|
|
42
|
+
*/
|
|
14
43
|
get supportedVersion() {
|
|
15
44
|
return { min: CLAPPR_VERSION };
|
|
16
45
|
}
|
|
@@ -34,20 +63,27 @@ export class Statistics extends ContainerPlugin {
|
|
|
34
63
|
assert(this.options.statistics &&
|
|
35
64
|
typeof this.options.statistics.send === 'function', 'Statistics plugin requires statistics options');
|
|
36
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
37
69
|
bindEvents() {
|
|
38
70
|
// TODO remove this
|
|
39
|
-
this.listenToOnce(
|
|
71
|
+
// this.listenToOnce(
|
|
72
|
+
// this.container,
|
|
73
|
+
// CUSTOM_EVENTS_CONTAINER_START,
|
|
74
|
+
// this.onStart,
|
|
75
|
+
// )
|
|
40
76
|
this.listenToOnce(this.container, Events.CONTAINER_READY, this.onReady);
|
|
41
77
|
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERING, this.onBuffering);
|
|
42
78
|
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERFULL, this.onBufferFull);
|
|
43
79
|
this.listenTo(this.container.playback, Events.PLAYBACK_TIMEUPDATE, this.onTimeUpdateLive);
|
|
44
80
|
this.listenTo(this.container.playback, Events.PLAYBACK_LEVEL_SWITCH_START, this.startLevelSwitch);
|
|
45
|
-
this.listenTo(this.container.playback, Events.PLAYBACK_LEVEL_SWITCH_END, this.
|
|
81
|
+
this.listenTo(this.container.playback, Events.PLAYBACK_LEVEL_SWITCH_END, this.endLevelSwitch);
|
|
46
82
|
}
|
|
47
83
|
startLevelSwitch() {
|
|
48
84
|
this.bufTracking = false;
|
|
49
85
|
}
|
|
50
|
-
|
|
86
|
+
endLevelSwitch() {
|
|
51
87
|
this.bufTracking = true;
|
|
52
88
|
}
|
|
53
89
|
onBuffering() {
|
|
@@ -63,12 +99,18 @@ export class Statistics extends ContainerPlugin {
|
|
|
63
99
|
this.bufTracking = true;
|
|
64
100
|
}
|
|
65
101
|
onReady() {
|
|
66
|
-
this.
|
|
102
|
+
this.sendInit();
|
|
103
|
+
trace(`${T} onReady`, {
|
|
104
|
+
autoPlay: this.options.autoPlay,
|
|
105
|
+
});
|
|
67
106
|
if (this.options.autoPlay) {
|
|
68
107
|
this.onStart();
|
|
69
108
|
}
|
|
109
|
+
else {
|
|
110
|
+
this.listenToOnce(this.container.playback, Events.PLAYBACK_PLAY_INTENT, this.onStart);
|
|
111
|
+
}
|
|
70
112
|
}
|
|
71
|
-
|
|
113
|
+
sendInit() {
|
|
72
114
|
this.sendMessage('init');
|
|
73
115
|
}
|
|
74
116
|
sendMessage(state) {
|
|
@@ -1,45 +1,94 @@
|
|
|
1
1
|
import { UICorePlugin } from '@clappr/core';
|
|
2
2
|
import '../../../assets/subtitles/style.scss';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A {@link MediaControl | media control} plugin that provides a UI to select the subtitles when available.
|
|
5
|
+
* @beta
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Depends on:
|
|
9
|
+
*
|
|
10
|
+
* - {@link MediaControl}
|
|
11
|
+
*
|
|
12
|
+
* Configuration options:
|
|
13
|
+
*
|
|
14
|
+
* - subtitles.language - The language of the subtitles to select by default.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Subtitles } from '@gcorevideo/player'
|
|
19
|
+
*
|
|
20
|
+
* Player.registerPlugin(Subtitles)
|
|
21
|
+
*
|
|
22
|
+
* new Player({
|
|
23
|
+
* ...
|
|
24
|
+
* subtitles: {
|
|
25
|
+
* language: 'en',
|
|
26
|
+
* },
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
4
30
|
export declare class Subtitles extends UICorePlugin {
|
|
5
|
-
private currentContainer;
|
|
6
31
|
private currentLevel;
|
|
7
|
-
private
|
|
32
|
+
private isPreselectedApplied;
|
|
8
33
|
private isShowing;
|
|
34
|
+
private track;
|
|
9
35
|
private tracks;
|
|
10
36
|
private $string;
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
11
40
|
get name(): string;
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
12
44
|
get supportedVersion(): {
|
|
13
45
|
min: string;
|
|
14
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
15
50
|
static get version(): string;
|
|
16
|
-
|
|
17
|
-
|
|
51
|
+
private static readonly template;
|
|
52
|
+
private static readonly templateString;
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
18
56
|
get attributes(): {
|
|
19
57
|
class: string;
|
|
20
58
|
'data-subtitles': string;
|
|
21
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
22
63
|
get events(): {
|
|
23
64
|
'click [data-subtitles-select]': string;
|
|
24
65
|
'click [data-subtitles-button]': string;
|
|
25
66
|
};
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
|
|
67
|
+
private get preselectedLanguage();
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
29
71
|
bindEvents(): void;
|
|
30
|
-
unBindEvents(): void;
|
|
31
72
|
private bindPlaybackEvents;
|
|
32
73
|
private getTracks;
|
|
33
74
|
private onStartAd;
|
|
34
75
|
private onFinishAd;
|
|
35
|
-
reload(): void;
|
|
36
76
|
private playerResize;
|
|
77
|
+
/**
|
|
78
|
+
* Hides the subtitles menu and the subtitles.
|
|
79
|
+
*/
|
|
37
80
|
hide(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Shows the subtitles menu and the subtitles.
|
|
83
|
+
*/
|
|
38
84
|
show(): void;
|
|
39
85
|
private shouldRender;
|
|
40
86
|
private resizeFont;
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
41
90
|
render(): this;
|
|
42
|
-
private
|
|
91
|
+
private setTracks;
|
|
43
92
|
private findLevelBy;
|
|
44
93
|
private selectLevel;
|
|
45
94
|
private onLevelSelect;
|
|
@@ -47,11 +96,11 @@ export declare class Subtitles extends UICorePlugin {
|
|
|
47
96
|
private onShowLevelSelectMenu;
|
|
48
97
|
private hideSelectLevelMenu;
|
|
49
98
|
private toggleContextMenu;
|
|
50
|
-
buttonElement
|
|
51
|
-
levelElement
|
|
52
|
-
startLevelSwitch
|
|
53
|
-
stopLevelSwitch
|
|
54
|
-
selectSubtitles
|
|
99
|
+
private buttonElement;
|
|
100
|
+
private levelElement;
|
|
101
|
+
private startLevelSwitch;
|
|
102
|
+
private stopLevelSwitch;
|
|
103
|
+
private selectSubtitles;
|
|
55
104
|
private setSubtitleText;
|
|
56
105
|
private clearSubtitleText;
|
|
57
106
|
private updateCurrentLevel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subtitles.d.ts","sourceRoot":"","sources":["../../../src/plugins/subtitles/Subtitles.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Subtitles.d.ts","sourceRoot":"","sources":["../../../src/plugins/subtitles/Subtitles.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAIb,MAAM,cAAc,CAAA;AAMrB,OAAO,sCAAsC,CAAA;AAuB7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,SAAU,SAAQ,YAAY;IACzC,OAAO,CAAC,YAAY,CAA6B;IAEjD,OAAO,CAAC,oBAAoB,CAAQ;IAEpC,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,KAAK,CAAiC;IAE9C,OAAO,CAAC,MAAM,CAA6B;IAE3C,OAAO,CAAC,OAAO,CAA2B;IAE1C;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED;;OAEG;IACH,MAAM,KAAK,OAAO,WAEjB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAuB;IAE7D;;OAEG;IACH,IAA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