@gcorevideo/player 2.24.3 → 2.24.6
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 +1424 -1424
- package/dist/index.embed.js +50978 -0
- package/dist/index.js +27 -15
- package/lib/Player.js +1 -1
- package/lib/index.embed.d.ts +34 -0
- package/lib/index.embed.d.ts.map +1 -0
- package/lib/index.embed.js +58 -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/seek-time/SeekTime.d.ts.map +1 -1
- package/lib/plugins/seek-time/SeekTime.js +1 -0
- 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 -2
- package/rollup.config.js +29 -0
- package/src/Player.ts +1 -1
- package/src/index.embed.ts +75 -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/seek-time/SeekTime.ts +1 -0
- package/src/plugins/source-controller/SourceController.ts +4 -2
- package/src/testUtils.ts +4 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/player.d.ts +0 -3267
- package/dist/plugins/index.css +0 -2047
- package/dist/plugins/index.js +0 -18918
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.6";
|
|
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();
|
|
@@ -50745,6 +50754,7 @@ class SeekTime extends UICorePlugin {
|
|
|
50745
50754
|
this.hoveringOverSeekBar = false;
|
|
50746
50755
|
this.update();
|
|
50747
50756
|
}
|
|
50757
|
+
// TODO delegate calculation to the MediaControl plugin
|
|
50748
50758
|
calculateHoverPosition(event) {
|
|
50749
50759
|
const mediaControl = this.core.getPlugin('media_control');
|
|
50750
50760
|
const offset = event.pageX - mediaControl.$seekBarContainer.offset().left;
|
|
@@ -51399,7 +51409,9 @@ class SourceController extends CorePlugin {
|
|
|
51399
51409
|
if (this.switching) {
|
|
51400
51410
|
return;
|
|
51401
51411
|
}
|
|
51402
|
-
|
|
51412
|
+
// The autoPlay metadata flag is set between a call to play and the actual playback start event, after which the flag is cleared.
|
|
51413
|
+
this.autoPlay =
|
|
51414
|
+
!!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay;
|
|
51403
51415
|
switch (error.code) {
|
|
51404
51416
|
case PlaybackErrorCode.MediaSourceUnavailable:
|
|
51405
51417
|
this.core.activeContainer?.getPlugin('poster')?.disable();
|
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,34 @@
|
|
|
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
|
+
import { PlayerMediaSource, PlayerConfig } from './index.core.js';
|
|
29
|
+
type Options = Partial<Omit<PlayerConfig, 'sources'>> & {
|
|
30
|
+
sources: PlayerMediaSource[];
|
|
31
|
+
};
|
|
32
|
+
export default function init(domNode: HTMLElement, options: Options): void;
|
|
33
|
+
export {};
|
|
34
|
+
//# 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,OAAO,EAAU,iBAAiB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA4BzE,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,GAAG;IACtD,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAC7B,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,QAelE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import { Player } from './index.core.js';
|
|
29
|
+
import { AudioTracks, BottomGear, MediaControl, ErrorScreen, SourceController, Subtitles, CmcdConfig, ClickToPause, DvrControls, PictureInPicture, Poster, Spinner, } from './index.plugins.js';
|
|
30
|
+
Player.registerPlugin(AudioTracks);
|
|
31
|
+
Player.registerPlugin(BottomGear);
|
|
32
|
+
Player.registerPlugin(ClickToPause);
|
|
33
|
+
Player.registerPlugin(CmcdConfig);
|
|
34
|
+
Player.registerPlugin(DvrControls);
|
|
35
|
+
Player.registerPlugin(ErrorScreen);
|
|
36
|
+
Player.registerPlugin(MediaControl);
|
|
37
|
+
Player.registerPlugin(PictureInPicture);
|
|
38
|
+
Player.registerPlugin(Poster);
|
|
39
|
+
Player.registerPlugin(SourceController);
|
|
40
|
+
Player.registerPlugin(Spinner);
|
|
41
|
+
Player.registerPlugin(Subtitles);
|
|
42
|
+
export default function init(domNode, options) {
|
|
43
|
+
const player = new Player({
|
|
44
|
+
autoPlay: true,
|
|
45
|
+
mute: true,
|
|
46
|
+
...options,
|
|
47
|
+
});
|
|
48
|
+
if (document.readyState === 'interactive') {
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
player.attachTo(domNode);
|
|
51
|
+
}, 0);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
55
|
+
player.attachTo(domNode);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -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":"SeekTime.d.ts","sourceRoot":"","sources":["../../../src/plugins/seek-time/SeekTime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,YAAY,EAAmB,MAAM,cAAc,CAAA;AAO9E,OAAO,0CAA0C,CAAA;AAEjD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAMD;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,YAAY;IACxC,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB;;MAEnB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD,IAAa,UAAU;;MAItB;IAED,OAAO,KAAK,mBAAmB,GAM9B;IAED,OAAO,KAAK,YAAY,GAKvB;IAED,OAAO,CAAC,mBAAmB,CAAQ;IAEnC,OAAO,CAAC,aAAa,CAAI;IAEzB,OAAO,CAAC,iBAAiB,CAAsB;IAE/C,OAAO,CAAC,iBAAiB,CAAsB;IAE/C,OAAO,CAAC,QAAQ,CAAI;IAEpB;;OAEG;IACM,UAAU;IASnB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,QAAQ;
|
|
1
|
+
{"version":3,"file":"SeekTime.d.ts","sourceRoot":"","sources":["../../../src/plugins/seek-time/SeekTime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,YAAY,EAAmB,MAAM,cAAc,CAAA;AAO9E,OAAO,0CAA0C,CAAA;AAEjD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAMD;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,YAAY;IACxC,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB;;MAEnB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD,IAAa,UAAU;;MAItB;IAED,OAAO,KAAK,mBAAmB,GAM9B;IAED,OAAO,KAAK,YAAY,GAKvB;IAED,OAAO,CAAC,mBAAmB,CAAQ;IAEnC,OAAO,CAAC,aAAa,CAAI;IAEzB,OAAO,CAAC,iBAAiB,CAAsB;IAE/C,OAAO,CAAC,iBAAiB,CAAsB;IAE/C,OAAO,CAAC,QAAQ,CAAI;IAEpB;;OAEG;IACM,UAAU;IASnB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,sBAAsB;IAW9B,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,MAAM;IA6Cd,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACM,MAAM;IAQf,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -72,6 +72,7 @@ export class SeekTime extends UICorePlugin {
|
|
|
72
72
|
this.hoveringOverSeekBar = false;
|
|
73
73
|
this.update();
|
|
74
74
|
}
|
|
75
|
+
// TODO delegate calculation to the MediaControl plugin
|
|
75
76
|
calculateHoverPosition(event) {
|
|
76
77
|
const mediaControl = this.core.getPlugin('media_control');
|
|
77
78
|
const offset = event.pageX - mediaControl.$seekBarContainer.offset().left;
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gcorevideo/player",
|
|
3
|
-
"version": "2.24.
|
|
3
|
+
"version": "2.24.6",
|
|
4
4
|
"description": "Gcore JavaScript video player",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "npm run build:ts && npm run build:bundle",
|
|
14
|
-
"build:1": "npm run build:ts && npm run build:bundle && date",
|
|
15
14
|
"build:ts": "tsc",
|
|
16
15
|
"build:bundle": "rollup -c",
|
|
17
16
|
"dev": "nodemon --watch src -e ts --exec \"npm run build:ts && npm run docs\"",
|
package/rollup.config.js
CHANGED
|
@@ -79,4 +79,33 @@ export default [
|
|
|
79
79
|
}
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
+
{
|
|
83
|
+
input: 'lib/index.embed.js',
|
|
84
|
+
plugins: [
|
|
85
|
+
resolve(), // TODO check which aren't inlined in the bundle and put them here
|
|
86
|
+
commonjs(),
|
|
87
|
+
json(),
|
|
88
|
+
polyfillNode(),
|
|
89
|
+
sass({
|
|
90
|
+
// output: 'dist/index.embed.css',
|
|
91
|
+
insert: true,
|
|
92
|
+
verbose: true,
|
|
93
|
+
}),
|
|
94
|
+
string({
|
|
95
|
+
include: [
|
|
96
|
+
'**/*.ejs',
|
|
97
|
+
'**/*.html',
|
|
98
|
+
'**/*.svg',
|
|
99
|
+
'**/*.worker.js',
|
|
100
|
+
],
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
output: [
|
|
104
|
+
{
|
|
105
|
+
file: 'dist/index.embed.js',
|
|
106
|
+
format: 'es',
|
|
107
|
+
generatedCode: 'es2015',
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
82
111
|
];
|
package/src/Player.ts
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
import { Player, PlayerMediaSource, PlayerConfig } from './index.core.js'
|
|
29
|
+
import {
|
|
30
|
+
AudioTracks,
|
|
31
|
+
BottomGear,
|
|
32
|
+
MediaControl,
|
|
33
|
+
ErrorScreen,
|
|
34
|
+
SourceController,
|
|
35
|
+
Subtitles,
|
|
36
|
+
CmcdConfig,
|
|
37
|
+
ClickToPause,
|
|
38
|
+
DvrControls,
|
|
39
|
+
PictureInPicture,
|
|
40
|
+
Poster,
|
|
41
|
+
Spinner,
|
|
42
|
+
} from './index.plugins.js'
|
|
43
|
+
|
|
44
|
+
Player.registerPlugin(AudioTracks)
|
|
45
|
+
Player.registerPlugin(BottomGear)
|
|
46
|
+
Player.registerPlugin(ClickToPause)
|
|
47
|
+
Player.registerPlugin(CmcdConfig)
|
|
48
|
+
Player.registerPlugin(DvrControls)
|
|
49
|
+
Player.registerPlugin(ErrorScreen)
|
|
50
|
+
Player.registerPlugin(MediaControl)
|
|
51
|
+
Player.registerPlugin(PictureInPicture)
|
|
52
|
+
Player.registerPlugin(Poster)
|
|
53
|
+
Player.registerPlugin(SourceController)
|
|
54
|
+
Player.registerPlugin(Spinner)
|
|
55
|
+
Player.registerPlugin(Subtitles)
|
|
56
|
+
type Options = Partial<Omit<PlayerConfig, 'sources'>> & {
|
|
57
|
+
sources: PlayerMediaSource[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default function init(domNode: HTMLElement, options: Options) {
|
|
61
|
+
const player = new Player({
|
|
62
|
+
autoPlay: true,
|
|
63
|
+
mute: true,
|
|
64
|
+
...options,
|
|
65
|
+
})
|
|
66
|
+
if (document.readyState === 'interactive') {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
player.attachTo(domNode)
|
|
69
|
+
}, 0)
|
|
70
|
+
} else {
|
|
71
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
72
|
+
player.attachTo(domNode)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -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
|
|