@gcorevideo/player 2.24.3 → 2.24.5
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 +2 -2
- package/dist/index.css +1326 -1326
- package/dist/index.js +26 -15
- package/dist/player.d.ts +7 -12
- package/lib/Player.js +1 -1
- package/lib/index.embed.d.ts +30 -0
- package/lib/index.embed.d.ts.map +1 -0
- package/lib/index.embed.js +29 -0
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +3 -0
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +19 -10
- package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
- package/lib/plugins/media-control/MediaControl.js +1 -1
- package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
- package/lib/plugins/source-controller/SourceController.js +3 -1
- package/lib/testUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Player.ts +1 -1
- package/src/index.embed.ts +29 -0
- package/src/plugins/big-mute-button/BigMuteButton.ts +30 -19
- package/src/plugins/big-mute-button/__tests__/BigMuteButton.test.ts +60 -12
- package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
- package/src/plugins/media-control/MediaControl.ts +1 -1
- package/src/plugins/source-controller/SourceController.ts +4 -2
- package/src/testUtils.ts +4 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -42836,7 +42836,7 @@ function registerPlaybacks() {
|
|
|
42836
42836
|
Loader.registerPlayback(DashPlayback);
|
|
42837
42837
|
}
|
|
42838
42838
|
|
|
42839
|
-
const T$k = '
|
|
42839
|
+
const T$k = 'gplayer';
|
|
42840
42840
|
const DEFAULT_OPTIONS = {
|
|
42841
42841
|
autoPlay: false,
|
|
42842
42842
|
debug: 'none',
|
|
@@ -43303,7 +43303,7 @@ class Player {
|
|
|
43303
43303
|
}
|
|
43304
43304
|
}
|
|
43305
43305
|
|
|
43306
|
-
var version$1 = "2.24.
|
|
43306
|
+
var version$1 = "2.24.5";
|
|
43307
43307
|
|
|
43308
43308
|
var packages = {
|
|
43309
43309
|
"node_modules/@clappr/core": {
|
|
@@ -44061,7 +44061,7 @@ class MediaControl extends UICorePlugin {
|
|
|
44061
44061
|
return false;
|
|
44062
44062
|
}
|
|
44063
44063
|
togglePlayStop() {
|
|
44064
|
-
this.container.isPlaying() ? this.container.stop() : this.container.play();
|
|
44064
|
+
this.container.isPlaying() ? this.container.stop({ ui: true }) : this.container.play();
|
|
44065
44065
|
}
|
|
44066
44066
|
startSeekDrag(event) {
|
|
44067
44067
|
if (!this.settings.seekEnabled) {
|
|
@@ -44964,6 +44964,7 @@ const T$h = 'plugins.big_mute_button';
|
|
|
44964
44964
|
* ```
|
|
44965
44965
|
*/
|
|
44966
44966
|
class BigMuteButton extends UICorePlugin {
|
|
44967
|
+
autoPlay = false;
|
|
44967
44968
|
hidden = false;
|
|
44968
44969
|
// TODO get back to the ads-related logic later
|
|
44969
44970
|
_adIsPlaying = false;
|
|
@@ -44985,7 +44986,7 @@ class BigMuteButton extends UICorePlugin {
|
|
|
44985
44986
|
*/
|
|
44986
44987
|
get events() {
|
|
44987
44988
|
return {
|
|
44988
|
-
|
|
44989
|
+
click: 'clicked',
|
|
44989
44990
|
};
|
|
44990
44991
|
}
|
|
44991
44992
|
/**
|
|
@@ -44997,34 +44998,42 @@ class BigMuteButton extends UICorePlugin {
|
|
|
44997
44998
|
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd);
|
|
44998
44999
|
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd);
|
|
44999
45000
|
}
|
|
45000
|
-
onCoreReady() {
|
|
45001
|
-
}
|
|
45001
|
+
onCoreReady() { }
|
|
45002
45002
|
onContainerChanged() {
|
|
45003
45003
|
this.listenTo(this.core.activeContainer, Events$1.CONTAINER_VOLUME, this.onContainerVolume);
|
|
45004
|
-
// this.listenTo(
|
|
45005
|
-
// this.core.activeContainer,
|
|
45006
|
-
// Events.CONTAINER_READY,
|
|
45007
|
-
// this.onContainerReady,
|
|
45008
|
-
// )
|
|
45009
45004
|
this.listenTo(this.core.activePlayback, Events$1.PLAYBACK_ENDED, this.onPlaybackEnded);
|
|
45010
45005
|
this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PLAY, this.onPlay);
|
|
45006
|
+
this.listenTo(this.core.activeContainer, Events$1.CONTAINER_STOP, this.onStop);
|
|
45007
|
+
this.listenTo(this.core.activeContainer, Events$1.CONTAINER_PAUSE, this.onPause);
|
|
45011
45008
|
}
|
|
45012
45009
|
onPlay(_, { autoPlay }) {
|
|
45013
45010
|
const container = this.core.activeContainer;
|
|
45014
45011
|
const { volume } = container;
|
|
45015
45012
|
const { wasMuted } = this.options;
|
|
45013
|
+
if (autoPlay) {
|
|
45014
|
+
this.autoPlay = true;
|
|
45015
|
+
}
|
|
45016
45016
|
trace(`${T$h} onPlay`, {
|
|
45017
|
-
autoPlay,
|
|
45017
|
+
autoPlay: this.autoPlay,
|
|
45018
45018
|
wasMuted,
|
|
45019
45019
|
volume,
|
|
45020
45020
|
});
|
|
45021
|
-
if (autoPlay && !wasMuted && volume === 0) {
|
|
45021
|
+
if (this.autoPlay && !wasMuted && volume === 0) {
|
|
45022
45022
|
this.mount();
|
|
45023
45023
|
}
|
|
45024
45024
|
else {
|
|
45025
45025
|
this.destroy();
|
|
45026
45026
|
}
|
|
45027
45027
|
}
|
|
45028
|
+
onStop(_, { ui }) {
|
|
45029
|
+
trace(`${T$h} onStop`, { ui });
|
|
45030
|
+
if (ui) {
|
|
45031
|
+
this.destroy();
|
|
45032
|
+
}
|
|
45033
|
+
}
|
|
45034
|
+
onPause() {
|
|
45035
|
+
this.destroy();
|
|
45036
|
+
}
|
|
45028
45037
|
onContainerVolume(value) {
|
|
45029
45038
|
if (value !== 0) {
|
|
45030
45039
|
this.destroy();
|
|
@@ -48392,7 +48401,7 @@ class ClickToPause extends ContainerPlugin {
|
|
|
48392
48401
|
togglePlay(useStop) {
|
|
48393
48402
|
const isPlaying = this.container && this.container.isPlaying();
|
|
48394
48403
|
if (isPlaying) {
|
|
48395
|
-
useStop ? this.container.stop() : this.container.pause();
|
|
48404
|
+
useStop ? this.container.stop({ ui: true }) : this.container.pause();
|
|
48396
48405
|
}
|
|
48397
48406
|
else {
|
|
48398
48407
|
this.container.play();
|
|
@@ -51399,7 +51408,9 @@ class SourceController extends CorePlugin {
|
|
|
51399
51408
|
if (this.switching) {
|
|
51400
51409
|
return;
|
|
51401
51410
|
}
|
|
51402
|
-
|
|
51411
|
+
// The autoPlay metadata flag is set between a call to play and the actual playback start event, after which the flag is cleared.
|
|
51412
|
+
this.autoPlay =
|
|
51413
|
+
!!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay;
|
|
51403
51414
|
switch (error.code) {
|
|
51404
51415
|
case PlaybackErrorCode.MediaSourceUnavailable:
|
|
51405
51416
|
this.core.activeContainer?.getPlugin('poster')?.disable();
|
package/dist/player.d.ts
CHANGED
|
@@ -120,10 +120,8 @@ export { AudioTracks }
|
|
|
120
120
|
* ```
|
|
121
121
|
*/
|
|
122
122
|
export declare class BigMuteButton extends UICorePlugin {
|
|
123
|
-
private
|
|
123
|
+
private hidden;
|
|
124
124
|
private _adIsPlaying;
|
|
125
|
-
private $bigMuteBtnContainer;
|
|
126
|
-
private $bigMuteButton;
|
|
127
125
|
/**
|
|
128
126
|
* @internal
|
|
129
127
|
*/
|
|
@@ -139,30 +137,26 @@ export declare class BigMuteButton extends UICorePlugin {
|
|
|
139
137
|
* @internal
|
|
140
138
|
*/
|
|
141
139
|
get events(): {
|
|
142
|
-
|
|
143
|
-
'click .big-mute-icon-wrapper': string;
|
|
140
|
+
click: string;
|
|
144
141
|
};
|
|
145
142
|
/**
|
|
146
143
|
* @internal
|
|
147
144
|
*/
|
|
148
145
|
bindEvents(): void;
|
|
149
146
|
private onCoreReady;
|
|
147
|
+
private onContainerChanged;
|
|
148
|
+
private onPlay;
|
|
150
149
|
private onContainerVolume;
|
|
151
|
-
private onContainerStart;
|
|
152
150
|
private onPlaybackEnded;
|
|
153
|
-
private onMediaControlRendered;
|
|
154
151
|
private onStartAd;
|
|
155
152
|
private onFinishAd;
|
|
156
|
-
private isActive;
|
|
157
153
|
/**
|
|
158
154
|
* @internal
|
|
159
155
|
*/
|
|
160
156
|
render(): this;
|
|
161
157
|
private mount;
|
|
162
|
-
private
|
|
163
|
-
private
|
|
164
|
-
private showBigMuteBtn;
|
|
165
|
-
private destroyBigMuteBtn;
|
|
158
|
+
private hide;
|
|
159
|
+
private show;
|
|
166
160
|
private clicked;
|
|
167
161
|
}
|
|
168
162
|
|
|
@@ -2757,6 +2751,7 @@ export declare class SourceController extends CorePlugin {
|
|
|
2757
2751
|
private currentSourceIndex;
|
|
2758
2752
|
private sourcesDelay;
|
|
2759
2753
|
private active;
|
|
2754
|
+
private autoPlay;
|
|
2760
2755
|
private switching;
|
|
2761
2756
|
private sync;
|
|
2762
2757
|
/**
|
package/lib/Player.js
CHANGED
|
@@ -5,7 +5,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
5
5
|
import { PlayerEvent } from './types.js';
|
|
6
6
|
import { buildMediaSourcesList, wrapSource } from './utils/mediaSources.js';
|
|
7
7
|
import { registerPlaybacks } from './playback/index.js';
|
|
8
|
-
const T = '
|
|
8
|
+
const T = 'gplayer';
|
|
9
9
|
const DEFAULT_OPTIONS = {
|
|
10
10
|
autoPlay: false,
|
|
11
11
|
debug: 'none',
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video player for the Gcore streaming platform
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This package provides a video player for the Gcore streaming platform.
|
|
6
|
+
* It is built on top of the {@link https://github.com/clappr/clappr | Clappr} library and provides a framework for building custom integrations.
|
|
7
|
+
* Start with {@link Player} for more information.
|
|
8
|
+
*
|
|
9
|
+
* Various plugins (marked with `PLUGIN` keyword) are available to extend the core functionality with additional features.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Player, MediaControl, ErrorScreen } from '@gcorevideo/player'
|
|
13
|
+
*
|
|
14
|
+
* Player.registerPlugin(MediaControl)
|
|
15
|
+
* Player.registerPlugin(ErrorScreen)
|
|
16
|
+
*
|
|
17
|
+
* const player = new Player({
|
|
18
|
+
* autoPlay: true,
|
|
19
|
+
* mute: true,
|
|
20
|
+
* sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* player.attachTo(document.getElementById('container'))
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
export * from './index.core.js';
|
|
29
|
+
export * from './index.plugins.js';
|
|
30
|
+
//# sourceMappingURL=index.embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.embed.d.ts","sourceRoot":"","sources":["../src/index.embed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video player for the Gcore streaming platform
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This package provides a video player for the Gcore streaming platform.
|
|
6
|
+
* It is built on top of the {@link https://github.com/clappr/clappr | Clappr} library and provides a framework for building custom integrations.
|
|
7
|
+
* Start with {@link Player} for more information.
|
|
8
|
+
*
|
|
9
|
+
* Various plugins (marked with `PLUGIN` keyword) are available to extend the core functionality with additional features.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Player, MediaControl, ErrorScreen } from '@gcorevideo/player'
|
|
13
|
+
*
|
|
14
|
+
* Player.registerPlugin(MediaControl)
|
|
15
|
+
* Player.registerPlugin(ErrorScreen)
|
|
16
|
+
*
|
|
17
|
+
* const player = new Player({
|
|
18
|
+
* autoPlay: true,
|
|
19
|
+
* mute: true,
|
|
20
|
+
* sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* player.attachTo(document.getElementById('container'))
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
export * from './index.core.js';
|
|
29
|
+
export * from './index.plugins.js';
|
|
@@ -12,6 +12,7 @@ import '../../../assets/big-mute-button/big-mute-button.scss';
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export declare class BigMuteButton extends UICorePlugin {
|
|
15
|
+
private autoPlay;
|
|
15
16
|
private hidden;
|
|
16
17
|
private _adIsPlaying;
|
|
17
18
|
/**
|
|
@@ -38,6 +39,8 @@ export declare class BigMuteButton extends UICorePlugin {
|
|
|
38
39
|
private onCoreReady;
|
|
39
40
|
private onContainerChanged;
|
|
40
41
|
private onPlay;
|
|
42
|
+
private onStop;
|
|
43
|
+
private onPause;
|
|
41
44
|
private onContainerVolume;
|
|
42
45
|
private onPlaybackEnded;
|
|
43
46
|
private onStartAd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BigMuteButton.d.ts","sourceRoot":"","sources":["../../../src/plugins/big-mute-button/BigMuteButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAS,MAAM,cAAc,CAAA;AAQpE,OAAO,sDAAsD,CAAA;AAM7D;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,YAAY;IAC7C,OAAO,CAAC,MAAM,CAAQ;IAGtB,OAAO,CAAC,YAAY,CAAQ;IAE5B;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD;;OAEG;IACH,IAAa,MAAM;;MAIlB;IAED;;OAEG;IACM,UAAU;
|
|
1
|
+
{"version":3,"file":"BigMuteButton.d.ts","sourceRoot":"","sources":["../../../src/plugins/big-mute-button/BigMuteButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAS,MAAM,cAAc,CAAA;AAQpE,OAAO,sDAAsD,CAAA;AAM7D;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,YAAY;IAC7C,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO,CAAC,MAAM,CAAQ;IAGtB,OAAO,CAAC,YAAY,CAAQ;IAE5B;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD;;OAEG;IACH,IAAa,MAAM;;MAIlB;IAED;;OAEG;IACM,UAAU;IAWnB,OAAO,CAAC,WAAW;IAEnB,OAAO,CAAC,kBAAkB;IAgB1B,OAAO,CAAC,MAAM;IAmBd,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,UAAU;IAKlB;;OAEG;IACM,MAAM;IAWf,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,OAAO;CAkBhB"}
|
|
@@ -18,6 +18,7 @@ const T = 'plugins.big_mute_button';
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export class BigMuteButton extends UICorePlugin {
|
|
21
|
+
autoPlay = false;
|
|
21
22
|
hidden = false;
|
|
22
23
|
// TODO get back to the ads-related logic later
|
|
23
24
|
_adIsPlaying = false;
|
|
@@ -39,7 +40,7 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
39
40
|
*/
|
|
40
41
|
get events() {
|
|
41
42
|
return {
|
|
42
|
-
|
|
43
|
+
click: 'clicked',
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
@@ -51,34 +52,42 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
51
52
|
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd);
|
|
52
53
|
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd);
|
|
53
54
|
}
|
|
54
|
-
onCoreReady() {
|
|
55
|
-
}
|
|
55
|
+
onCoreReady() { }
|
|
56
56
|
onContainerChanged() {
|
|
57
57
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_VOLUME, this.onContainerVolume);
|
|
58
|
-
// this.listenTo(
|
|
59
|
-
// this.core.activeContainer,
|
|
60
|
-
// Events.CONTAINER_READY,
|
|
61
|
-
// this.onContainerReady,
|
|
62
|
-
// )
|
|
63
58
|
this.listenTo(this.core.activePlayback, Events.PLAYBACK_ENDED, this.onPlaybackEnded);
|
|
64
59
|
this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAY, this.onPlay);
|
|
60
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_STOP, this.onStop);
|
|
61
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PAUSE, this.onPause);
|
|
65
62
|
}
|
|
66
63
|
onPlay(_, { autoPlay }) {
|
|
67
64
|
const container = this.core.activeContainer;
|
|
68
65
|
const { volume } = container;
|
|
69
66
|
const { wasMuted } = this.options;
|
|
67
|
+
if (autoPlay) {
|
|
68
|
+
this.autoPlay = true;
|
|
69
|
+
}
|
|
70
70
|
trace(`${T} onPlay`, {
|
|
71
|
-
autoPlay,
|
|
71
|
+
autoPlay: this.autoPlay,
|
|
72
72
|
wasMuted,
|
|
73
73
|
volume,
|
|
74
74
|
});
|
|
75
|
-
if (autoPlay && !wasMuted && volume === 0) {
|
|
75
|
+
if (this.autoPlay && !wasMuted && volume === 0) {
|
|
76
76
|
this.mount();
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
this.destroy();
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
onStop(_, { ui }) {
|
|
83
|
+
trace(`${T} onStop`, { ui });
|
|
84
|
+
if (ui) {
|
|
85
|
+
this.destroy();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
onPause() {
|
|
89
|
+
this.destroy();
|
|
90
|
+
}
|
|
82
91
|
onContainerVolume(value) {
|
|
83
92
|
if (value !== 0) {
|
|
84
93
|
this.destroy();
|
|
@@ -62,7 +62,7 @@ export class ClickToPause extends ContainerPlugin {
|
|
|
62
62
|
togglePlay(useStop) {
|
|
63
63
|
const isPlaying = this.container && this.container.isPlaying();
|
|
64
64
|
if (isPlaying) {
|
|
65
|
-
useStop ? this.container.stop() : this.container.pause();
|
|
65
|
+
useStop ? this.container.stop({ ui: true }) : this.container.pause();
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
68
|
this.container.play();
|
|
@@ -483,7 +483,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
483
483
|
return false;
|
|
484
484
|
}
|
|
485
485
|
togglePlayStop() {
|
|
486
|
-
this.container.isPlaying() ? this.container.stop() : this.container.play();
|
|
486
|
+
this.container.isPlaying() ? this.container.stop({ ui: true }) : this.container.play();
|
|
487
487
|
}
|
|
488
488
|
startSeekDrag(event) {
|
|
489
489
|
if (!this.settings.seekEnabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceController.d.ts","sourceRoot":"","sources":["../../../src/plugins/source-controller/SourceController.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,KAAK,IAAI,IAAI,UAAU,EACxB,MAAM,cAAc,CAAA;AAwBrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAwC9C,OAAO,CAAC,WAAW,CAA8B;IAEjD,OAAO,CAAC,kBAAkB,CAAI;IAE9B,OAAO,CAAC,YAAY,CAA6B;IAEjD,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,IAAI,CAAiB;IAE7B;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED;;OAEG;gBACS,IAAI,EAAE,UAAU;IAW5B;;OAEG;IACM,UAAU;IAWnB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,2BAA2B;
|
|
1
|
+
{"version":3,"file":"SourceController.d.ts","sourceRoot":"","sources":["../../../src/plugins/source-controller/SourceController.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,KAAK,IAAI,IAAI,UAAU,EACxB,MAAM,cAAc,CAAA;AAwBrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAwC9C,OAAO,CAAC,WAAW,CAA8B;IAEjD,OAAO,CAAC,kBAAkB,CAAI;IAE9B,OAAO,CAAC,YAAY,CAA6B;IAEjD,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,IAAI,CAAiB;IAE7B;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED;;OAEG;gBACS,IAAI,EAAE,UAAU;IAW5B;;OAEG;IACM,UAAU;IAWnB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,2BAA2B;IAqDnC,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,aAAa;IA+BrB,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,MAAM,KAAK,OAAO,WAEjB;CACF"}
|
|
@@ -184,7 +184,9 @@ export class SourceController extends CorePlugin {
|
|
|
184
184
|
if (this.switching) {
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
// The autoPlay metadata flag is set between a call to play and the actual playback start event, after which the flag is cleared.
|
|
188
|
+
this.autoPlay =
|
|
189
|
+
!!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay;
|
|
188
190
|
switch (error.code) {
|
|
189
191
|
case PlaybackErrorCode.MediaSourceUnavailable:
|
|
190
192
|
this.core.activeContainer?.getPlugin('poster')?.disable();
|
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,EAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,MAAM,MAAM,eAAe,CAAA;AAGlC,wBAAgB,cAAc,CAC5B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACrC,SAAS,GAAE,GAAkC;;;;;;;;;;;;;;;;;EAsB9C;AAED,wBAAgB,gBAAgB;;;EAK/B;AAED,wBAAgB,mBAAmB;;;;;;EAKlC;AAED,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,MAAM,MAAM,eAAe,CAAA;AAGlC,wBAAgB,cAAc,CAC5B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACrC,SAAS,GAAE,GAAkC;;;;;;;;;;;;;;;;;EAsB9C;AAED,wBAAgB,gBAAgB;;;EAK/B;AAED,wBAAgB,mBAAmB;;;;;;EAKlC;AAED,wBAAgB,kBAAkB,CAChC,IAAI,SAAS,EACb,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCtC;AAED,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACrC,QAAQ,GAAE,GAAgD;;;;;;;;;;;;;;;;;;;;;;;;;EA8B3D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,gBAmB/C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,OAe7C"}
|
package/package.json
CHANGED
package/src/Player.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video player for the Gcore streaming platform
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This package provides a video player for the Gcore streaming platform.
|
|
6
|
+
* It is built on top of the {@link https://github.com/clappr/clappr | Clappr} library and provides a framework for building custom integrations.
|
|
7
|
+
* Start with {@link Player} for more information.
|
|
8
|
+
*
|
|
9
|
+
* Various plugins (marked with `PLUGIN` keyword) are available to extend the core functionality with additional features.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Player, MediaControl, ErrorScreen } from '@gcorevideo/player'
|
|
13
|
+
*
|
|
14
|
+
* Player.registerPlugin(MediaControl)
|
|
15
|
+
* Player.registerPlugin(ErrorScreen)
|
|
16
|
+
*
|
|
17
|
+
* const player = new Player({
|
|
18
|
+
* autoPlay: true,
|
|
19
|
+
* mute: true,
|
|
20
|
+
* sources: [{ source: 'https://example.com/a.mpd', mimeType: 'application/dash+xml' }],
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* player.attachTo(document.getElementById('container'))
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
export * from './index.core.js'
|
|
29
|
+
export * from './index.plugins.js'
|
|
@@ -24,6 +24,8 @@ const T = 'plugins.big_mute_button'
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export class BigMuteButton extends UICorePlugin {
|
|
27
|
+
private autoPlay = false
|
|
28
|
+
|
|
27
29
|
private hidden = false
|
|
28
30
|
|
|
29
31
|
// TODO get back to the ads-related logic later
|
|
@@ -50,7 +52,7 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
50
52
|
*/
|
|
51
53
|
override get events() {
|
|
52
54
|
return {
|
|
53
|
-
|
|
55
|
+
click: 'clicked',
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -59,14 +61,16 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
59
61
|
*/
|
|
60
62
|
override bindEvents() {
|
|
61
63
|
this.listenTo(this.core, Events.CORE_READY, this.onCoreReady)
|
|
62
|
-
this.listenTo(
|
|
64
|
+
this.listenTo(
|
|
65
|
+
this.core,
|
|
66
|
+
Events.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
67
|
+
this.onContainerChanged,
|
|
68
|
+
)
|
|
63
69
|
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
64
70
|
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
private onCoreReady() {
|
|
68
|
-
|
|
69
|
-
}
|
|
73
|
+
private onCoreReady() {}
|
|
70
74
|
|
|
71
75
|
private onContainerChanged() {
|
|
72
76
|
this.listenTo(
|
|
@@ -74,39 +78,46 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
74
78
|
Events.CONTAINER_VOLUME,
|
|
75
79
|
this.onContainerVolume,
|
|
76
80
|
)
|
|
77
|
-
// this.listenTo(
|
|
78
|
-
// this.core.activeContainer,
|
|
79
|
-
// Events.CONTAINER_READY,
|
|
80
|
-
// this.onContainerReady,
|
|
81
|
-
// )
|
|
82
81
|
this.listenTo(
|
|
83
82
|
this.core.activePlayback,
|
|
84
83
|
Events.PLAYBACK_ENDED,
|
|
85
84
|
this.onPlaybackEnded,
|
|
86
85
|
)
|
|
87
|
-
this.listenTo(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.onPlay
|
|
91
|
-
)
|
|
86
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAY, this.onPlay)
|
|
87
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_STOP, this.onStop)
|
|
88
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PAUSE, this.onPause)
|
|
92
89
|
}
|
|
93
90
|
|
|
94
|
-
private onPlay(_: string, { autoPlay }: { autoPlay?: boolean}) {
|
|
91
|
+
private onPlay(_: string, { autoPlay }: { autoPlay?: boolean }) {
|
|
95
92
|
const container = this.core.activeContainer
|
|
96
93
|
const { volume } = container
|
|
97
94
|
const { wasMuted } = this.options
|
|
95
|
+
if (autoPlay) {
|
|
96
|
+
this.autoPlay = true
|
|
97
|
+
}
|
|
98
98
|
trace(`${T} onPlay`, {
|
|
99
|
-
autoPlay,
|
|
99
|
+
autoPlay: this.autoPlay,
|
|
100
100
|
wasMuted,
|
|
101
101
|
volume,
|
|
102
102
|
})
|
|
103
|
-
if (autoPlay && !wasMuted && volume === 0) {
|
|
103
|
+
if (this.autoPlay && !wasMuted && volume === 0) {
|
|
104
104
|
this.mount()
|
|
105
105
|
} else {
|
|
106
106
|
this.destroy()
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
private onStop(_: string, { ui }: { ui?: boolean }) {
|
|
111
|
+
trace(`${T} onStop`, { ui })
|
|
112
|
+
if (ui) {
|
|
113
|
+
this.destroy()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private onPause() {
|
|
118
|
+
this.destroy()
|
|
119
|
+
}
|
|
120
|
+
|
|
110
121
|
private onContainerVolume(value: number) {
|
|
111
122
|
if (value !== 0) {
|
|
112
123
|
this.destroy()
|
|
@@ -134,7 +145,7 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
134
145
|
trace(`${T} render`)
|
|
135
146
|
this.$el.html(BigMuteButton.template())
|
|
136
147
|
this.$el.find('#gplayer-big-mute-icon').append(volumeMuteIcon)
|
|
137
|
-
|
|
148
|
+
|
|
138
149
|
// TODO
|
|
139
150
|
// this._adIsPlaying && this.hide()
|
|
140
151
|
|
|
@@ -4,16 +4,19 @@ import { Events } from '@clappr/core'
|
|
|
4
4
|
import { BigMuteButton } from '../BigMuteButton.js'
|
|
5
5
|
import { createMockCore } from '../../../testUtils.js'
|
|
6
6
|
|
|
7
|
+
// import { Logger, LogTracer, setTracer } from '@gcorevideo/utils'
|
|
8
|
+
|
|
9
|
+
// setTracer(new LogTracer('BigMuteButton.test'))
|
|
10
|
+
// Logger.enable('*')
|
|
11
|
+
|
|
7
12
|
describe('BigMuteButton', () => {
|
|
8
13
|
let core: any
|
|
9
14
|
let bmb: BigMuteButton
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
core = createMockCore({})
|
|
17
|
+
bmb = new BigMuteButton(core)
|
|
18
|
+
})
|
|
10
19
|
describe('basically', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
core = createMockCore({})
|
|
13
|
-
bmb = new BigMuteButton(core)
|
|
14
|
-
// core.emit('core:ready')
|
|
15
|
-
// core.emit('core:active:container:changed')
|
|
16
|
-
})
|
|
17
20
|
it('should render', () => {
|
|
18
21
|
expect(bmb.$el.html()).toMatchSnapshot()
|
|
19
22
|
})
|
|
@@ -22,17 +25,62 @@ describe('BigMuteButton', () => {
|
|
|
22
25
|
describe.each([
|
|
23
26
|
['muted autoplay', 0, { autoPlay: true }, true],
|
|
24
27
|
['audible autoplay', 50, { autoPlay: true }, false],
|
|
25
|
-
['muted not autoplay', 0, {
|
|
26
|
-
['audible not autoplay',
|
|
27
|
-
])(
|
|
28
|
+
['muted not autoplay', 0, {}, false],
|
|
29
|
+
['audible not autoplay', 50, {}, false],
|
|
30
|
+
])('%s', (_, volume, playMetadata, shouldMount) => {
|
|
28
31
|
beforeEach(() => {
|
|
29
32
|
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
|
|
30
33
|
core.activeContainer.volume = volume
|
|
31
|
-
core.activeContainer.emit(
|
|
34
|
+
core.activeContainer.emit(
|
|
35
|
+
Events.CONTAINER_PLAY,
|
|
36
|
+
'Container',
|
|
37
|
+
playMetadata,
|
|
38
|
+
)
|
|
32
39
|
})
|
|
33
40
|
it(`should ${shouldMount ? 'mount' : 'not mount'} to container`, () => {
|
|
34
|
-
expect(
|
|
41
|
+
expect(
|
|
42
|
+
core.activeContainer.$el.find('#gplayer-big-mute-button').length,
|
|
43
|
+
).toBe(shouldMount ? 1 : 0)
|
|
35
44
|
})
|
|
36
45
|
})
|
|
37
46
|
})
|
|
38
|
-
|
|
47
|
+
describe('when playback is stopped', () => {
|
|
48
|
+
describe.each([
|
|
49
|
+
['from ui', { ui: true }, true],
|
|
50
|
+
['algorithmically', {}, false],
|
|
51
|
+
])('%s', (_, stopMetadata, shouldUnmount) => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
|
|
54
|
+
core.activeContainer.volume = 0
|
|
55
|
+
core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', {
|
|
56
|
+
autoPlay: true,
|
|
57
|
+
})
|
|
58
|
+
core.activeContainer.emit(
|
|
59
|
+
Events.CONTAINER_STOP,
|
|
60
|
+
'Container',
|
|
61
|
+
stopMetadata,
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
it(`should ${shouldUnmount ? 'unmount' : 'not unmount'}`, () => {
|
|
65
|
+
expect(
|
|
66
|
+
core.activeContainer.$el.find('#gplayer-big-mute-button').length,
|
|
67
|
+
).toBe(shouldUnmount ? 0 : 1)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
describe('when playback is paused', () => {
|
|
72
|
+
beforeEach(() => {
|
|
73
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
|
|
74
|
+
core.activeContainer.volume = 0
|
|
75
|
+
core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', {
|
|
76
|
+
autoPlay: true,
|
|
77
|
+
})
|
|
78
|
+
core.activeContainer.emit(Events.CONTAINER_PAUSE, 'Container')
|
|
79
|
+
})
|
|
80
|
+
it('should unmount', () => {
|
|
81
|
+
expect(
|
|
82
|
+
core.activeContainer.$el.find('#gplayer-big-mute-button').length,
|
|
83
|
+
).toBe(0)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -85,7 +85,7 @@ export class ClickToPause extends ContainerPlugin {
|
|
|
85
85
|
const isPlaying = this.container && this.container.isPlaying()
|
|
86
86
|
|
|
87
87
|
if (isPlaying) {
|
|
88
|
-
useStop ? this.container.stop() : this.container.pause()
|
|
88
|
+
useStop ? this.container.stop({ ui: true }) : this.container.pause()
|
|
89
89
|
} else {
|
|
90
90
|
this.container.play()
|
|
91
91
|
}
|
|
@@ -723,7 +723,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
private togglePlayStop() {
|
|
726
|
-
this.container.isPlaying() ? this.container.stop() : this.container.play()
|
|
726
|
+
this.container.isPlaying() ? this.container.stop({ ui: true }) : this.container.play()
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
private startSeekDrag(event: MouseEvent) {
|