@gcorevideo/player 2.22.30 → 2.22.31
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/media-control/container.scss +2 -3
- package/assets/poster/poster.ejs +3 -1
- package/assets/poster/poster.scss +3 -3
- package/assets/style/main.scss +1 -1
- package/dist/core.js +1 -1
- package/dist/index.css +670 -671
- package/dist/index.js +68 -98
- package/dist/player.d.ts +63 -33
- package/docs/api/{player.seektime.bindevents.md → player.clapprstats.clearmetrics.md} +3 -3
- package/docs/api/player.clapprstats.md +14 -0
- package/docs/api/player.extendedevents.md +14 -0
- package/docs/api/player.md +13 -2
- package/docs/api/player.seektime.attributes.md +0 -1
- package/docs/api/player.seektime.md +6 -197
- package/docs/api/{player.seektime.render.md → player.seektimesettings.md} +7 -7
- package/docs/api/player.skiptime.md +3 -184
- package/lib/plugins/poster/Poster.d.ts +24 -14
- package/lib/plugins/poster/Poster.d.ts.map +1 -1
- package/lib/plugins/poster/Poster.js +67 -97
- package/lib/testUtils.d.ts +13 -39
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +14 -65
- package/package.json +1 -1
- package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +1 -1
- package/src/plugins/poster/Poster.ts +91 -110
- package/src/plugins/poster/__tests__/Poster.test.ts +119 -0
- package/src/plugins/poster/__tests__/__snapshots__/Poster.test.ts.snap +8 -0
- package/src/plugins/source-controller/__tests__/SourceController.test.ts +1 -2
- package/src/testUtils.ts +14 -86
- package/temp/player.api.json +295 -829
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.seektime.durationshown.md +0 -14
- package/docs/api/player.seektime.getseektime.md +0 -20
- package/docs/api/player.seektime.islivestreamwithdvr.md +0 -14
- package/docs/api/player.seektime.mediacontrol.md +0 -14
- package/docs/api/player.seektime.mediacontrolcontainer.md +0 -14
- package/docs/api/player.seektime.shouldbevisible.md +0 -18
- package/docs/api/player.seektime.template.md +0 -14
- package/docs/api/player.seektime.update.md +0 -18
- package/docs/api/player.skiptime.attributes.md +0 -17
- package/docs/api/player.skiptime.bindevents.md +0 -18
- package/docs/api/player.skiptime.events.md +0 -18
- package/docs/api/player.skiptime.handlerewindclicks.md +0 -18
- package/docs/api/player.skiptime.render.md +0 -18
- package/docs/api/player.skiptime.setback.md +0 -18
- package/docs/api/player.skiptime.setforward.md +0 -18
- package/docs/api/player.skiptime.setmidclick.md +0 -18
- package/docs/api/player.skiptime.template.md +0 -14
- package/docs/api/player.skiptime.togglefullscreen.md +0 -18
|
@@ -1,7 +1,7 @@
|
|
|
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, Playback, PlayerError, UIContainerPlugin, template,
|
|
4
|
+
import { Events, Playback, PlayerError, UIContainerPlugin, template, } from '@clappr/core';
|
|
5
5
|
import { trace } from '@gcorevideo/utils';
|
|
6
6
|
import { CLAPPR_VERSION } from '../../build.js';
|
|
7
7
|
import '../../../assets/poster/poster.scss';
|
|
@@ -12,19 +12,13 @@ const T = 'plugins.poster';
|
|
|
12
12
|
* `PLUGIN` that displays a poster image in the background and a big play button on top when playback is stopped
|
|
13
13
|
* @beta
|
|
14
14
|
* @remarks
|
|
15
|
-
* When the playback is stopped, media control UI is disabled.
|
|
15
|
+
* When the playback is stopped or not yet started, the media control UI is disabled and hidden.
|
|
16
|
+
* Media control gets activated once the metadata is loaded after playback is initiated.
|
|
17
|
+
* This plugin displays a big play button on top of the poster image to allow user to start playback.
|
|
16
18
|
* Note that the poster image, if specified via the player config, will be used to update video element's poster attribute by the
|
|
17
19
|
* HTML5-video-based playback module.
|
|
18
20
|
*
|
|
19
|
-
* Configuration options
|
|
20
|
-
*
|
|
21
|
-
* - `poster.custom` - custom CSS background
|
|
22
|
-
*
|
|
23
|
-
* - `poster.showForNoOp` - whether to show the poster when the playback is not started
|
|
24
|
-
*
|
|
25
|
-
* - `poster.url` - the URL of the poster image
|
|
26
|
-
*
|
|
27
|
-
* - `poster.showOnVideoEnd` - whether to show the poster when the playback is ended
|
|
21
|
+
* Configuration options - {@link PosterPluginSettings}
|
|
28
22
|
*
|
|
29
23
|
* @example
|
|
30
24
|
* ```ts
|
|
@@ -40,10 +34,9 @@ const T = 'plugins.poster';
|
|
|
40
34
|
export class Poster extends UIContainerPlugin {
|
|
41
35
|
// TODO merge non-poster related functionality into the ClickToPause plugin
|
|
42
36
|
hasFatalError = false;
|
|
43
|
-
|
|
37
|
+
playing = false;
|
|
44
38
|
playRequested = false;
|
|
45
39
|
$playButton = null;
|
|
46
|
-
$playWrapper = null;
|
|
47
40
|
/**
|
|
48
41
|
* @internal
|
|
49
42
|
*/
|
|
@@ -63,8 +56,10 @@ export class Poster extends UIContainerPlugin {
|
|
|
63
56
|
}
|
|
64
57
|
const showForNoOp = !!this.options.poster?.showForNoOp;
|
|
65
58
|
return (this.container.playback.name !== 'html_img' &&
|
|
66
|
-
(this.
|
|
67
|
-
|
|
59
|
+
(!this.isNoOp || showForNoOp));
|
|
60
|
+
}
|
|
61
|
+
get isNoOp() {
|
|
62
|
+
return this.container.playback.getPlaybackType() === Playback.NO_OP;
|
|
68
63
|
}
|
|
69
64
|
/**
|
|
70
65
|
* @internal
|
|
@@ -72,7 +67,6 @@ export class Poster extends UIContainerPlugin {
|
|
|
72
67
|
get attributes() {
|
|
73
68
|
return {
|
|
74
69
|
class: 'player-poster',
|
|
75
|
-
'data-poster': '',
|
|
76
70
|
};
|
|
77
71
|
}
|
|
78
72
|
/**
|
|
@@ -83,9 +77,6 @@ export class Poster extends UIContainerPlugin {
|
|
|
83
77
|
click: 'clicked',
|
|
84
78
|
};
|
|
85
79
|
}
|
|
86
|
-
get showOnVideoEnd() {
|
|
87
|
-
return this.options.poster?.showOnVideoEnd !== false;
|
|
88
|
-
}
|
|
89
80
|
/**
|
|
90
81
|
* @internal
|
|
91
82
|
*/
|
|
@@ -94,19 +85,22 @@ export class Poster extends UIContainerPlugin {
|
|
|
94
85
|
this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay);
|
|
95
86
|
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERING, this.update);
|
|
96
87
|
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERFULL, this.update);
|
|
97
|
-
this.listenTo(this.container, Events.CONTAINER_OPTIONS_CHANGE, this.
|
|
88
|
+
this.listenTo(this.container, Events.CONTAINER_OPTIONS_CHANGE, this.update);
|
|
98
89
|
this.listenTo(this.container, Events.CONTAINER_ERROR, this.onError);
|
|
99
|
-
this
|
|
90
|
+
// TODO check if this event is always accompanied with the CONTAINER_STOP
|
|
91
|
+
if (this.options.poster?.showOnVideoEnd !== false) {
|
|
100
92
|
this.listenTo(this.container, Events.CONTAINER_ENDED, this.onStop);
|
|
93
|
+
}
|
|
101
94
|
this.listenTo(this.container, Events.CONTAINER_READY, this.render);
|
|
102
|
-
this.listenTo(this.container, Events.PLAYBACK_PLAY_INTENT, this.onPlayIntent);
|
|
95
|
+
this.listenTo(this.container.playback, Events.PLAYBACK_PLAY_INTENT, this.onPlayIntent);
|
|
103
96
|
}
|
|
104
97
|
/**
|
|
105
98
|
* Reenables earlier disabled plugin
|
|
106
99
|
*/
|
|
107
100
|
enable() {
|
|
101
|
+
trace(`${T} enable`);
|
|
108
102
|
super.enable();
|
|
109
|
-
this.
|
|
103
|
+
this.playing = this.container.playback.isPlaying();
|
|
110
104
|
this.update();
|
|
111
105
|
}
|
|
112
106
|
/**
|
|
@@ -114,7 +108,7 @@ export class Poster extends UIContainerPlugin {
|
|
|
114
108
|
*/
|
|
115
109
|
disable() {
|
|
116
110
|
trace(`${T} disable`);
|
|
117
|
-
this.
|
|
111
|
+
this.playing = false;
|
|
118
112
|
this.playRequested = false;
|
|
119
113
|
super.disable();
|
|
120
114
|
}
|
|
@@ -123,17 +117,15 @@ export class Poster extends UIContainerPlugin {
|
|
|
123
117
|
error,
|
|
124
118
|
enabled: this.enabled,
|
|
125
119
|
});
|
|
126
|
-
this.hasFatalError = error.level === PlayerError.Levels.FATAL;
|
|
127
120
|
if (this.hasFatalError) {
|
|
128
|
-
|
|
129
|
-
if (!this.playRequested) {
|
|
130
|
-
this.showPlayButton();
|
|
131
|
-
}
|
|
121
|
+
return;
|
|
132
122
|
}
|
|
123
|
+
this.hasFatalError = error.level === PlayerError.Levels.FATAL;
|
|
124
|
+
// this.hasFatalError is reset on container recreate
|
|
133
125
|
}
|
|
134
126
|
onPlay() {
|
|
135
127
|
trace(`${T} onPlay`);
|
|
136
|
-
this.
|
|
128
|
+
this.playing = true;
|
|
137
129
|
this.playRequested = false;
|
|
138
130
|
this.update();
|
|
139
131
|
}
|
|
@@ -143,21 +135,21 @@ export class Poster extends UIContainerPlugin {
|
|
|
143
135
|
this.update();
|
|
144
136
|
}
|
|
145
137
|
onStop() {
|
|
146
|
-
trace(`${T} onStop
|
|
147
|
-
|
|
148
|
-
});
|
|
149
|
-
this.hasStartedPlaying = false;
|
|
138
|
+
trace(`${T} onStop`);
|
|
139
|
+
this.playing = false;
|
|
150
140
|
this.playRequested = false;
|
|
151
141
|
this.update();
|
|
152
142
|
}
|
|
153
|
-
updatePlayButton(
|
|
154
|
-
trace(`${T} updatePlayButton
|
|
155
|
-
|
|
156
|
-
chromeless
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
143
|
+
updatePlayButton() {
|
|
144
|
+
trace(`${T} updatePlayButton`);
|
|
145
|
+
const show = !this.isNoOp &&
|
|
146
|
+
!(this.options.chromeless && !this.options.allowUserInteraction) &&
|
|
147
|
+
!this.playRequested &&
|
|
148
|
+
!this.playing &&
|
|
149
|
+
!this.container.buffering &&
|
|
150
|
+
!this.hasFatalError &&
|
|
151
|
+
!this.options.disableMediaControl;
|
|
152
|
+
if (show) {
|
|
161
153
|
this.showPlayButton();
|
|
162
154
|
}
|
|
163
155
|
else {
|
|
@@ -165,59 +157,42 @@ export class Poster extends UIContainerPlugin {
|
|
|
165
157
|
}
|
|
166
158
|
}
|
|
167
159
|
showPlayButton() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
if (this.hasFatalError && !this.options.disableErrorScreen) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
this.$playButton?.show();
|
|
160
|
+
trace(`${T} showPlayButton`);
|
|
161
|
+
this.$el.find('#poster-play').show();
|
|
175
162
|
this.$el.addClass('clickable');
|
|
176
163
|
this.container.$el.addClass('container-with-poster-clickable');
|
|
177
164
|
}
|
|
178
165
|
hidePlayButton() {
|
|
179
|
-
|
|
166
|
+
trace(`${T} hidePlayButton`);
|
|
167
|
+
this.$el.find('#poster-play').hide();
|
|
180
168
|
this.$el.removeClass('clickable');
|
|
181
169
|
}
|
|
182
|
-
clicked() {
|
|
183
|
-
trace(`${T} clicked
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
170
|
+
clicked(e) {
|
|
171
|
+
trace(`${T} clicked`);
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
if (this.options.chromeless && !this.options.allowUserInteraction) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
188
177
|
// Let "click_to_pause" plugin handle click event if media has started playing
|
|
189
|
-
if (!this.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.container.playback.consent();
|
|
194
|
-
this.container.playback.play();
|
|
195
|
-
}
|
|
178
|
+
if (!this.playing) {
|
|
179
|
+
this.playRequested = true;
|
|
180
|
+
this.update();
|
|
181
|
+
this.container.play();
|
|
196
182
|
}
|
|
197
|
-
return false;
|
|
198
183
|
}
|
|
199
184
|
shouldHideOnPlay() {
|
|
200
185
|
// Audio broadcasts should keep the poster up; video should hide poster while playing.
|
|
201
186
|
return !this.container.playback.isAudioOnly;
|
|
202
187
|
}
|
|
203
188
|
update() {
|
|
204
|
-
trace(`${T} update
|
|
205
|
-
|
|
206
|
-
});
|
|
207
|
-
if (!this.shouldRender) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
const showPlayButton = !this.playRequested &&
|
|
211
|
-
!this.hasStartedPlaying &&
|
|
212
|
-
!this.container.buffering;
|
|
213
|
-
this.updatePlayButton(showPlayButton);
|
|
189
|
+
trace(`${T} update`);
|
|
190
|
+
this.updatePlayButton();
|
|
214
191
|
this.updatePoster();
|
|
215
192
|
}
|
|
216
193
|
updatePoster() {
|
|
217
|
-
trace(`${T} updatePoster
|
|
218
|
-
|
|
219
|
-
});
|
|
220
|
-
if (!this.hasStartedPlaying) {
|
|
194
|
+
trace(`${T} updatePoster`);
|
|
195
|
+
if (!this.playing) {
|
|
221
196
|
this.showPoster();
|
|
222
197
|
}
|
|
223
198
|
else {
|
|
@@ -229,9 +204,7 @@ export class Poster extends UIContainerPlugin {
|
|
|
229
204
|
this.$el.show();
|
|
230
205
|
}
|
|
231
206
|
hidePoster() {
|
|
232
|
-
trace(`${T} hidePoster
|
|
233
|
-
shouldHideOnPlay: this.shouldHideOnPlay(),
|
|
234
|
-
});
|
|
207
|
+
trace(`${T} hidePoster`);
|
|
235
208
|
if (!this.options.disableMediaControl) {
|
|
236
209
|
this.container.enableMediaControl();
|
|
237
210
|
}
|
|
@@ -247,27 +220,24 @@ export class Poster extends UIContainerPlugin {
|
|
|
247
220
|
return this;
|
|
248
221
|
}
|
|
249
222
|
this.$el.html(Poster.template());
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
252
|
-
const posterUrl = this.options.poster.url || this.options.poster;
|
|
253
|
-
this.$el.css({ 'background-image': 'url(' + posterUrl + ')' });
|
|
254
|
-
}
|
|
255
|
-
else if (this.options.poster) {
|
|
223
|
+
const isCustomPoster = this.options.poster?.custom !== undefined;
|
|
224
|
+
if (isCustomPoster) {
|
|
256
225
|
this.$el.css({ background: this.options.poster.custom });
|
|
257
226
|
}
|
|
227
|
+
else {
|
|
228
|
+
const posterUrl = typeof this.options.poster === 'string'
|
|
229
|
+
? this.options.poster
|
|
230
|
+
: this.options.poster?.url;
|
|
231
|
+
if (posterUrl) {
|
|
232
|
+
this.$el.css({ 'background-image': 'url(' + posterUrl + ')' });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
258
235
|
this.container.$el.removeClass('container-with-poster-clickable');
|
|
259
236
|
this.container.$el.append(this.el);
|
|
260
|
-
this.$
|
|
261
|
-
this
|
|
262
|
-
|
|
263
|
-
this.$playWrapper.append(this.$playButton);
|
|
264
|
-
this.$playButton.append(playIcon);
|
|
265
|
-
if (this.options.autoPlay) {
|
|
266
|
-
this.$playButton.hide();
|
|
237
|
+
this.$el.find('#poster-play').append(playIcon);
|
|
238
|
+
if (this.options.autoPlay || this.isNoOp) {
|
|
239
|
+
this.$el.find('#poster-play').hide();
|
|
267
240
|
}
|
|
268
|
-
this.$playButton.addClass('poster-icon');
|
|
269
|
-
this.$playButton.attr('data-poster', '');
|
|
270
|
-
this.update();
|
|
271
241
|
return this;
|
|
272
242
|
}
|
|
273
243
|
/**
|
package/lib/testUtils.d.ts
CHANGED
|
@@ -1,39 +1,5 @@
|
|
|
1
1
|
import { UICorePlugin } from '@clappr/core';
|
|
2
2
|
import Events from 'eventemitter3';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
* @deprecated
|
|
6
|
-
* TODO use createMockPlayback() instead
|
|
7
|
-
*/
|
|
8
|
-
export declare class _MockPlayback extends Events {
|
|
9
|
-
protected options: any;
|
|
10
|
-
readonly i18n: any;
|
|
11
|
-
protected playerError?: any | undefined;
|
|
12
|
-
constructor(options: any, i18n: any, playerError?: any | undefined);
|
|
13
|
-
get name(): string;
|
|
14
|
-
consent(): void;
|
|
15
|
-
play(): void;
|
|
16
|
-
pause(): void;
|
|
17
|
-
stop(): void;
|
|
18
|
-
destroy(): void;
|
|
19
|
-
seek(): void;
|
|
20
|
-
seekPercentage(): void;
|
|
21
|
-
getDuration(): number;
|
|
22
|
-
enterPiP(): void;
|
|
23
|
-
exitPiP(): void;
|
|
24
|
-
getPlaybackType(): string;
|
|
25
|
-
getStartTimeOffset(): number;
|
|
26
|
-
getCurrentTime(): number;
|
|
27
|
-
isHighDefinitionInUse(): boolean;
|
|
28
|
-
mute(): void;
|
|
29
|
-
unmute(): void;
|
|
30
|
-
volume(): void;
|
|
31
|
-
configure(): void;
|
|
32
|
-
attemptAutoPlay(): boolean;
|
|
33
|
-
canAutoPlay(): boolean;
|
|
34
|
-
onResize(): boolean;
|
|
35
|
-
trigger(event: string, ...args: any[]): void;
|
|
36
|
-
}
|
|
37
3
|
export declare function createMockCore(options?: Record<string, unknown>, container?: any): Events<string | symbol, any> & {
|
|
38
4
|
el: HTMLDivElement;
|
|
39
5
|
$el: any;
|
|
@@ -68,11 +34,12 @@ export declare function createMockPlayback(name?: string): Events<string | symbo
|
|
|
68
34
|
el: HTMLVideoElement;
|
|
69
35
|
dvrEnabled: boolean;
|
|
70
36
|
dvrInUse: boolean;
|
|
37
|
+
isAudioOnly: boolean;
|
|
71
38
|
levels: never[];
|
|
72
|
-
consent():
|
|
73
|
-
play():
|
|
74
|
-
pause():
|
|
75
|
-
stop():
|
|
39
|
+
consent: import("vitest").Mock<(...args: any[]) => any>;
|
|
40
|
+
play: import("vitest").Mock<(...args: any[]) => any>;
|
|
41
|
+
pause: import("vitest").Mock<(...args: any[]) => any>;
|
|
42
|
+
stop: import("vitest").Mock<(...args: any[]) => any>;
|
|
76
43
|
destroy: import("vitest").Mock<(...args: any[]) => any>;
|
|
77
44
|
seek: import("vitest").Mock<(...args: any[]) => any>;
|
|
78
45
|
seekPercentage: import("vitest").Mock<(...args: any[]) => any>;
|
|
@@ -97,13 +64,20 @@ export declare function createMockPlayback(name?: string): Events<string | symbo
|
|
|
97
64
|
export declare function createMockContainer(options?: Record<string, unknown>, playback?: any): Events<string | symbol, any> & {
|
|
98
65
|
el: any;
|
|
99
66
|
playback: any;
|
|
100
|
-
options:
|
|
67
|
+
options: {
|
|
68
|
+
[x: string]: unknown;
|
|
69
|
+
};
|
|
101
70
|
$el: any;
|
|
71
|
+
disableMediaControl: import("vitest").Mock<(...args: any[]) => any>;
|
|
72
|
+
enableMediaControl: import("vitest").Mock<(...args: any[]) => any>;
|
|
73
|
+
enterPiP: import("vitest").Mock<(...args: any[]) => any>;
|
|
74
|
+
exitPiP: import("vitest").Mock<(...args: any[]) => any>;
|
|
102
75
|
getDuration: import("vitest").Mock<(...args: any[]) => any>;
|
|
103
76
|
getPlugin: import("vitest").Mock<(...args: any[]) => any>;
|
|
104
77
|
getPlaybackType: import("vitest").Mock<(...args: any[]) => any>;
|
|
105
78
|
isDvrInUse: import("vitest").Mock<(...args: any[]) => any>;
|
|
106
79
|
isDvrEnabled: import("vitest").Mock<(...args: any[]) => any>;
|
|
80
|
+
isHighDefinitionInUse: import("vitest").Mock<(...args: any[]) => any>;
|
|
107
81
|
isPlaying: import("vitest").Mock<(...args: any[]) => any>;
|
|
108
82
|
play: import("vitest").Mock<(...args: any[]) => any>;
|
|
109
83
|
seek: import("vitest").Mock<(...args: any[]) => any>;
|
package/lib/testUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../src/testUtils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;;;;;;;;;;;;;;;;EAqB9C;AAED,wBAAgB,gBAAgB;;;EAK/B;AAED,wBAAgB,mBAAmB;;;;;;EAKlC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmC/C;AAED,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACrC,QAAQ,GAAE,GAA0B;;;;;;;;;;;;;;;;;;;;;;;EA4BrC;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,gBAe/C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,OAe7C"}
|
package/lib/testUtils.js
CHANGED
|
@@ -1,65 +1,6 @@
|
|
|
1
|
-
import { $,
|
|
1
|
+
import { $, UICorePlugin } from '@clappr/core';
|
|
2
2
|
import Events from 'eventemitter3';
|
|
3
3
|
import { vi } from 'vitest';
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
* @deprecated
|
|
7
|
-
* TODO use createMockPlayback() instead
|
|
8
|
-
*/
|
|
9
|
-
export class _MockPlayback extends Events {
|
|
10
|
-
options;
|
|
11
|
-
i18n;
|
|
12
|
-
playerError;
|
|
13
|
-
constructor(options, i18n, playerError) {
|
|
14
|
-
super();
|
|
15
|
-
this.options = options;
|
|
16
|
-
this.i18n = i18n;
|
|
17
|
-
this.playerError = playerError;
|
|
18
|
-
}
|
|
19
|
-
get name() {
|
|
20
|
-
return 'mock';
|
|
21
|
-
}
|
|
22
|
-
consent() { }
|
|
23
|
-
play() { }
|
|
24
|
-
pause() { }
|
|
25
|
-
stop() { }
|
|
26
|
-
destroy() { }
|
|
27
|
-
seek() { }
|
|
28
|
-
seekPercentage() { }
|
|
29
|
-
getDuration() {
|
|
30
|
-
return 100;
|
|
31
|
-
}
|
|
32
|
-
enterPiP() { }
|
|
33
|
-
exitPiP() { }
|
|
34
|
-
getPlaybackType() {
|
|
35
|
-
return Playback.LIVE;
|
|
36
|
-
}
|
|
37
|
-
getStartTimeOffset() {
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
getCurrentTime() {
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
isHighDefinitionInUse() {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
mute() { }
|
|
47
|
-
unmute() { }
|
|
48
|
-
volume() { }
|
|
49
|
-
configure() { }
|
|
50
|
-
attemptAutoPlay() {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
canAutoPlay() {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
onResize() {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
trigger(event, ...args) {
|
|
60
|
-
this.emit(event, ...args);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
4
|
export function createMockCore(options = {}, container = createMockContainer(options)) {
|
|
64
5
|
const el = document.createElement('div');
|
|
65
6
|
const emitter = new Events();
|
|
@@ -101,11 +42,12 @@ export function createMockPlayback(name = 'mock') {
|
|
|
101
42
|
el: document.createElement('video'),
|
|
102
43
|
dvrEnabled: false,
|
|
103
44
|
dvrInUse: false,
|
|
45
|
+
isAudioOnly: false,
|
|
104
46
|
levels: [],
|
|
105
|
-
consent()
|
|
106
|
-
play()
|
|
107
|
-
pause()
|
|
108
|
-
stop()
|
|
47
|
+
consent: vi.fn(),
|
|
48
|
+
play: vi.fn(),
|
|
49
|
+
pause: vi.fn(),
|
|
50
|
+
stop: vi.fn(),
|
|
109
51
|
destroy: vi.fn(),
|
|
110
52
|
seek: vi.fn(),
|
|
111
53
|
seekPercentage: vi.fn(),
|
|
@@ -134,13 +76,20 @@ export function createMockContainer(options = {}, playback = createMockPlayback(
|
|
|
134
76
|
return Object.assign(emitter, {
|
|
135
77
|
el,
|
|
136
78
|
playback,
|
|
137
|
-
options
|
|
79
|
+
options: {
|
|
80
|
+
...options,
|
|
81
|
+
},
|
|
138
82
|
$el: $(el),
|
|
83
|
+
disableMediaControl: vi.fn(),
|
|
84
|
+
enableMediaControl: vi.fn(),
|
|
85
|
+
enterPiP: vi.fn(),
|
|
86
|
+
exitPiP: vi.fn(),
|
|
139
87
|
getDuration: vi.fn().mockReturnValue(0),
|
|
140
88
|
getPlugin: vi.fn(),
|
|
141
89
|
getPlaybackType: vi.fn(),
|
|
142
90
|
isDvrInUse: vi.fn().mockReturnValue(false),
|
|
143
91
|
isDvrEnabled: vi.fn().mockReturnValue(false),
|
|
92
|
+
isHighDefinitionInUse: vi.fn().mockReturnValue(false),
|
|
144
93
|
isPlaying: vi.fn().mockReturnValue(false),
|
|
145
94
|
play: vi.fn(),
|
|
146
95
|
seek: vi.fn(),
|
package/package.json
CHANGED
|
@@ -246,7 +246,7 @@ exports[`MediaControl > rendering timing > once metadata is loaded > should wait
|
|
|
246
246
|
<span class="drawer-text" data-volume=""></span>
|
|
247
247
|
</div>
|
|
248
248
|
|
|
249
|
-
<div class="bar-container
|
|
249
|
+
<div class="bar-container" data-volume="">
|
|
250
250
|
<div class="bar-background" data-volume="">
|
|
251
251
|
<div class="bar-fill-1 gcore-skin-main-color" data-volume="" style="width: 100%;"></div>
|
|
252
252
|
</div>
|