@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
|
@@ -9,31 +9,56 @@ import '../../../assets/picture-in-picture/button.scss';
|
|
|
9
9
|
|
|
10
10
|
const VERSION = '0.0.1';
|
|
11
11
|
|
|
12
|
-
const T = `plugins.
|
|
13
|
-
|
|
12
|
+
const T = `plugins.pip`;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Enables picture in picture mode.
|
|
16
|
+
* @beta
|
|
17
|
+
* @remarks
|
|
18
|
+
* Depends on:
|
|
19
|
+
*
|
|
20
|
+
* - {@link MediaControl}
|
|
21
|
+
*
|
|
22
|
+
* It renders a button to toggle picture in picture mode in the media control UI.
|
|
23
|
+
*/
|
|
14
24
|
export class PictureInPicture extends UICorePlugin {
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
15
28
|
get name() {
|
|
16
|
-
return '
|
|
29
|
+
return 'pip';
|
|
17
30
|
}
|
|
18
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
19
35
|
get supportedVersion() {
|
|
20
36
|
return { min: CLAPPR_VERSION };
|
|
21
37
|
}
|
|
22
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
23
42
|
static get version() {
|
|
24
43
|
return VERSION;
|
|
25
44
|
}
|
|
26
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
27
49
|
override get events() {
|
|
28
50
|
return {
|
|
29
51
|
'click button': 'togglePictureInPicture',
|
|
30
52
|
};
|
|
31
53
|
}
|
|
32
54
|
|
|
33
|
-
get videoElement() {
|
|
55
|
+
private get videoElement() {
|
|
34
56
|
return this.core.activePlayback.el;
|
|
35
57
|
}
|
|
36
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
37
62
|
override bindEvents() {
|
|
38
63
|
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_RENDERED, this.render);
|
|
39
64
|
}
|
|
@@ -47,6 +72,9 @@ export class PictureInPicture extends UICorePlugin {
|
|
|
47
72
|
return document.pictureInPictureEnabled && !!HTMLVideoElement.prototype.requestPictureInPicture;
|
|
48
73
|
}
|
|
49
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
50
78
|
override render() {
|
|
51
79
|
if (!this.isPiPSupported()) {
|
|
52
80
|
return this;
|
|
@@ -64,7 +92,7 @@ export class PictureInPicture extends UICorePlugin {
|
|
|
64
92
|
return this;
|
|
65
93
|
}
|
|
66
94
|
|
|
67
|
-
togglePictureInPicture() {
|
|
95
|
+
private togglePictureInPicture() {
|
|
68
96
|
trace(`${T} togglePictureInPicture`);
|
|
69
97
|
if (this.videoElement !== document.pictureInPictureElement) {
|
|
70
98
|
this.requestPictureInPicture();
|
|
@@ -73,14 +101,14 @@ export class PictureInPicture extends UICorePlugin {
|
|
|
73
101
|
}
|
|
74
102
|
}
|
|
75
103
|
|
|
76
|
-
requestPictureInPicture() {
|
|
104
|
+
private requestPictureInPicture() {
|
|
77
105
|
trace(`${T} requestPictureInPicture`, {
|
|
78
106
|
videoElement: !!this.videoElement,
|
|
79
107
|
});
|
|
80
108
|
this.videoElement.requestPictureInPicture();
|
|
81
109
|
}
|
|
82
110
|
|
|
83
|
-
exitPictureInPicture() {
|
|
111
|
+
private exitPictureInPicture() {
|
|
84
112
|
trace(`${T} exitPictureInPicture`);
|
|
85
113
|
document.exitPictureInPicture();
|
|
86
114
|
}
|
|
@@ -31,6 +31,19 @@ const DEFAULT_PLAYBACK_RATE = '1.0';
|
|
|
31
31
|
// TODO
|
|
32
32
|
const MEDIACONTROL_PLAYBACKRATE = 'playbackRate';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Allows changing the playback speed of the video.
|
|
36
|
+
* @beta
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Depends on:
|
|
40
|
+
*
|
|
41
|
+
* - {@link MediaControl | media_control}
|
|
42
|
+
*
|
|
43
|
+
* - {@link BottomGear | bottom_gear}
|
|
44
|
+
*
|
|
45
|
+
* It renders a button in the gear menu, which opens a dropdown with the available playback rates.
|
|
46
|
+
*/
|
|
34
47
|
export class PlaybackRate extends UICorePlugin {
|
|
35
48
|
private currentPlayback: Playback | null = null;
|
|
36
49
|
|
|
@@ -40,18 +53,29 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
40
53
|
|
|
41
54
|
private selectedRate: string = DEFAULT_PLAYBACK_RATE;
|
|
42
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
43
59
|
get name() {
|
|
44
|
-
return '
|
|
60
|
+
return 'playback_rate';
|
|
45
61
|
}
|
|
46
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
47
66
|
get supportedVersion() {
|
|
48
67
|
return { min: CLAPPR_VERSION };
|
|
49
68
|
}
|
|
50
69
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
private static readonly template = template(pluginHtml);
|
|
71
|
+
|
|
72
|
+
private static readonly buttonTemplate = template(buttonHtml);
|
|
73
|
+
|
|
74
|
+
private static readonly listTemplate = template(listHtml);
|
|
54
75
|
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
55
79
|
override get attributes() {
|
|
56
80
|
return {
|
|
57
81
|
'class': this.name,
|
|
@@ -59,6 +83,9 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
59
83
|
};
|
|
60
84
|
}
|
|
61
85
|
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
62
89
|
override get events() {
|
|
63
90
|
return {
|
|
64
91
|
'click .gear-sub-menu_btn': 'onRateSelect',
|
|
@@ -67,8 +94,12 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
67
94
|
};
|
|
68
95
|
}
|
|
69
96
|
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
70
100
|
override bindEvents() {
|
|
71
101
|
this.listenTo(this.core, 'gear:rendered', this.render);
|
|
102
|
+
// TODO this.core.getPlugin('media_control'), bottom_gear
|
|
72
103
|
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
|
|
73
104
|
this.listenTo(this.core.mediaControl, MEDIACONTROL_PLAYBACKRATE, this.updatePlaybackRate);
|
|
74
105
|
|
|
@@ -87,7 +118,7 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
87
118
|
}
|
|
88
119
|
}
|
|
89
120
|
|
|
90
|
-
unBindEvents() {
|
|
121
|
+
private unBindEvents() {
|
|
91
122
|
this.stopListening(this.core, 'gear:rendered', this.render);
|
|
92
123
|
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
|
|
93
124
|
this.stopListening(this.core, 'core:advertisement:start', this.onStartAd);
|
|
@@ -121,7 +152,7 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
121
152
|
}
|
|
122
153
|
}
|
|
123
154
|
|
|
124
|
-
reload() {
|
|
155
|
+
private reload() {
|
|
125
156
|
this.unBindEvents();
|
|
126
157
|
this.bindEvents();
|
|
127
158
|
}
|
|
@@ -136,6 +167,9 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
136
167
|
return !(this.currentPlayback?.tagName !== 'video' && this.currentPlayback?.tagName !== 'audio');
|
|
137
168
|
}
|
|
138
169
|
|
|
170
|
+
/**
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
139
173
|
override render() {
|
|
140
174
|
const container = this.core.activeContainer;
|
|
141
175
|
|
|
@@ -153,9 +187,7 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
153
187
|
}
|
|
154
188
|
|
|
155
189
|
if (this.shouldRender()) {
|
|
156
|
-
const
|
|
157
|
-
// const html = t({ playbackRates: this.playbackRates, title: this.getTitle() });
|
|
158
|
-
const button = t({
|
|
190
|
+
const button = PlaybackRate.buttonTemplate({
|
|
159
191
|
title: this.getTitle(),
|
|
160
192
|
speedIcon,
|
|
161
193
|
arrowRightIcon,
|
|
@@ -177,19 +209,19 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
177
209
|
return this;
|
|
178
210
|
}
|
|
179
211
|
|
|
180
|
-
onStartAd() {
|
|
212
|
+
private onStartAd() {
|
|
181
213
|
this.prevSelectedRate = this.selectedRate;
|
|
182
214
|
this.setSelectedRate('1.0');
|
|
183
215
|
this.listenToOnce(this.currentPlayback, Events.PLAYBACK_PLAY, this.onFinishAd);
|
|
184
216
|
}
|
|
185
217
|
|
|
186
|
-
onFinishAd() {
|
|
218
|
+
private onFinishAd() {
|
|
187
219
|
if (this.prevSelectedRate) {
|
|
188
220
|
this.setSelectedRate(this.prevSelectedRate);
|
|
189
221
|
}
|
|
190
222
|
}
|
|
191
223
|
|
|
192
|
-
onPlay() {
|
|
224
|
+
private onPlay() {
|
|
193
225
|
if (!this.core.mediaControl.$el.hasClass('dvr')) {
|
|
194
226
|
if (this.core.getPlaybackType() === Playback.LIVE) {
|
|
195
227
|
this.updatePlaybackRate(DEFAULT_PLAYBACK_RATE);
|
|
@@ -200,11 +232,10 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
200
232
|
}
|
|
201
233
|
}
|
|
202
234
|
|
|
203
|
-
onStop() {
|
|
204
|
-
|
|
235
|
+
private onStop() {
|
|
205
236
|
}
|
|
206
237
|
|
|
207
|
-
onRateSelect(event: MouseEvent) {
|
|
238
|
+
private onRateSelect(event: MouseEvent) {
|
|
208
239
|
event.stopPropagation();
|
|
209
240
|
const rate = (event.currentTarget as HTMLElement).dataset.rate;
|
|
210
241
|
if (rate) {
|
|
@@ -215,10 +246,8 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
215
246
|
return false;
|
|
216
247
|
}
|
|
217
248
|
|
|
218
|
-
onShowMenu() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.$el.html(t({
|
|
249
|
+
private onShowMenu() {
|
|
250
|
+
this.$el.html(PlaybackRate.listTemplate({
|
|
222
251
|
playbackRates: this.playbackRates,
|
|
223
252
|
arrowLeftIcon,
|
|
224
253
|
checkIcon,
|
|
@@ -228,15 +257,15 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
228
257
|
this.highlightCurrentRate();
|
|
229
258
|
}
|
|
230
259
|
|
|
231
|
-
goBack() {
|
|
260
|
+
private goBack() {
|
|
232
261
|
this.core.trigger('gear:refresh');
|
|
233
262
|
}
|
|
234
263
|
|
|
235
|
-
updatePlaybackRate(rate: string) {
|
|
264
|
+
private updatePlaybackRate(rate: string) {
|
|
236
265
|
this.setSelectedRate(rate);
|
|
237
266
|
}
|
|
238
267
|
|
|
239
|
-
setSelectedRate(rate: string) {
|
|
268
|
+
private setSelectedRate(rate: string) {
|
|
240
269
|
// Set <video playbackRate="..."
|
|
241
270
|
this.core.$el.find('video,audio').get(0).playbackRate = rate;
|
|
242
271
|
this.selectedRate = rate;
|
|
@@ -244,7 +273,7 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
244
273
|
// Player.player.trigger('playbackRateChanged', rate);
|
|
245
274
|
}
|
|
246
275
|
|
|
247
|
-
getTitle() {
|
|
276
|
+
private getTitle() {
|
|
248
277
|
let title = this.selectedRate;
|
|
249
278
|
|
|
250
279
|
this.playbackRates.forEach((r) => {
|
|
@@ -256,7 +285,7 @@ export class PlaybackRate extends UICorePlugin {
|
|
|
256
285
|
return title;
|
|
257
286
|
}
|
|
258
287
|
|
|
259
|
-
highlightCurrentRate() {
|
|
288
|
+
private highlightCurrentRate() {
|
|
260
289
|
this.allRateElements().removeClass('current');
|
|
261
290
|
this.allRateElements().find('a').removeClass('gcore-skin-active');
|
|
262
291
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type PlayerMediaSourceDesc,
|
|
12
12
|
} from '../../types.js'
|
|
13
13
|
import { trace } from '@gcorevideo/utils'
|
|
14
|
+
import { SpinnerEvents } from '../spinner-three-bounce/SpinnerThreeBounce.js'
|
|
14
15
|
|
|
15
16
|
import { CLAPPR_VERSION } from '../../build.js'
|
|
16
17
|
|
|
@@ -96,10 +97,16 @@ export class SourceController extends CorePlugin {
|
|
|
96
97
|
|
|
97
98
|
private sync: SyncFn = noSync
|
|
98
99
|
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
99
103
|
get name() {
|
|
100
104
|
return 'source_controller'
|
|
101
105
|
}
|
|
102
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
103
110
|
get supportedVersion() {
|
|
104
111
|
return { min: CLAPPR_VERSION }
|
|
105
112
|
}
|
|
@@ -132,7 +139,7 @@ export class SourceController extends CorePlugin {
|
|
|
132
139
|
const spinner = this.core.activeContainer?.getPlugin('spinner')
|
|
133
140
|
if (spinner) {
|
|
134
141
|
this.sync = (cb: () => void) => {
|
|
135
|
-
spinner.once(
|
|
142
|
+
spinner.once(SpinnerEvents.SYNC, cb)
|
|
136
143
|
}
|
|
137
144
|
} else {
|
|
138
145
|
this.sync = noSync
|
|
@@ -228,6 +235,9 @@ export class SourceController extends CorePlugin {
|
|
|
228
235
|
})
|
|
229
236
|
}
|
|
230
237
|
|
|
238
|
+
/**
|
|
239
|
+
* @internal
|
|
240
|
+
*/
|
|
231
241
|
static get version() {
|
|
232
242
|
return VERSION
|
|
233
243
|
}
|
|
@@ -146,7 +146,7 @@ describe('SourceController', () => {
|
|
|
146
146
|
it('should sync with the spinner before reloading the source', async () => {
|
|
147
147
|
await clock.tickAsync(1000)
|
|
148
148
|
expect(core.load).not.toHaveBeenCalled()
|
|
149
|
-
spinner.emit('spinner:sync')
|
|
149
|
+
spinner.emit('plugins:spinner:sync')
|
|
150
150
|
expect(core.load).toHaveBeenCalled()
|
|
151
151
|
})
|
|
152
152
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
|
|
5
|
-
import { Container, Events, UIContainerPlugin, template } from '@clappr/core';
|
|
5
|
+
import { Container, Events as ClapprEvents, UIContainerPlugin, template } from '@clappr/core';
|
|
6
6
|
import { PlaybackError, PlaybackErrorCode } from '../../playback.types.js';
|
|
7
7
|
import { trace } from '@gcorevideo/utils';
|
|
8
8
|
|
|
@@ -13,15 +13,41 @@ import { CLAPPR_VERSION } from '../../build.js';
|
|
|
13
13
|
|
|
14
14
|
const T = 'plugins.spinner'
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Custom events emitted by the plugin
|
|
18
|
+
*/
|
|
19
|
+
export enum SpinnerEvents {
|
|
20
|
+
/**
|
|
21
|
+
* Emitted at the end of the spinner animation cycle to facilitate smooth UI updates,
|
|
22
|
+
* e.g. {@link SourceController} listens to this event to reload the source when the spinner is hidden
|
|
23
|
+
*/
|
|
24
|
+
SYNC = 'plugins:spinner:sync',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Shows a pending operation indicator when playback is buffering or in other appropriate cases
|
|
29
|
+
* @beta
|
|
30
|
+
* @remarks
|
|
31
|
+
* The plugin emits
|
|
32
|
+
*/
|
|
16
33
|
export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
17
37
|
get name() {
|
|
18
38
|
return 'spinner';
|
|
19
39
|
}
|
|
20
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
21
44
|
get supportedVersion() {
|
|
22
45
|
return { min: CLAPPR_VERSION };
|
|
23
46
|
}
|
|
24
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
25
51
|
override get attributes() {
|
|
26
52
|
return {
|
|
27
53
|
'data-spinner':'',
|
|
@@ -39,13 +65,13 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
39
65
|
|
|
40
66
|
constructor(container: Container) {
|
|
41
67
|
super(container);
|
|
42
|
-
this.listenTo(this.container,
|
|
43
|
-
this.listenTo(this.container,
|
|
44
|
-
this.listenTo(this.container,
|
|
45
|
-
this.listenTo(this.container,
|
|
46
|
-
this.listenTo(this.container,
|
|
47
|
-
this.listenTo(this.container,
|
|
48
|
-
this.listenTo(this.container,
|
|
68
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_STATE_BUFFERING, this.onBuffering);
|
|
69
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_STATE_BUFFERFULL, this.onBufferFull);
|
|
70
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_PLAY, this.onPlay);
|
|
71
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_STOP, this.onStop);
|
|
72
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_ENDED, this.onStop);
|
|
73
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_ERROR, this.onError);
|
|
74
|
+
this.listenTo(this.container, ClapprEvents.CONTAINER_READY, this.render);
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
private onBuffering() {
|
|
@@ -90,21 +116,16 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
90
116
|
}
|
|
91
117
|
}
|
|
92
118
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (this.showTimeout !== null) {
|
|
99
|
-
clearTimeout(this.showTimeout);
|
|
100
|
-
this.showTimeout = null;
|
|
101
|
-
}
|
|
102
|
-
this.$el.show();
|
|
103
|
-
} else if (this.showTimeout === null) {
|
|
104
|
-
this.showTimeout = setTimeout(() => this.$el.show(), 300);
|
|
105
|
-
}
|
|
119
|
+
/**
|
|
120
|
+
* Shows the spinner
|
|
121
|
+
*/
|
|
122
|
+
show() {
|
|
123
|
+
this.showTimeout = setTimeout(() => this.$el.show(), 300);
|
|
106
124
|
}
|
|
107
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Hides the spinner
|
|
128
|
+
*/
|
|
108
129
|
hide() {
|
|
109
130
|
if (this.showTimeout !== null) {
|
|
110
131
|
clearTimeout(this.showTimeout);
|
|
@@ -113,6 +134,9 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
113
134
|
this.$el.hide();
|
|
114
135
|
}
|
|
115
136
|
|
|
137
|
+
/**
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
116
140
|
override render() {
|
|
117
141
|
const showOnStart = this.options.spinner?.showOnStart;
|
|
118
142
|
trace(`${T} render`, {
|
|
@@ -121,7 +145,7 @@ export class SpinnerThreeBounce extends UIContainerPlugin {
|
|
|
121
145
|
})
|
|
122
146
|
this.$el.html(this.template());
|
|
123
147
|
this.el.firstElementChild?.addEventListener('animationiteration', () => {
|
|
124
|
-
this.trigger(
|
|
148
|
+
this.trigger(SpinnerEvents.SYNC)
|
|
125
149
|
})
|
|
126
150
|
this.container.$el.append(this.$el[0]);
|
|
127
151
|
if (showOnStart || this.container.buffering) {
|