@gcorevideo/player 2.23.0 → 2.23.2
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/bottom-gear/bottomgear.ejs +5 -2
- package/dist/core.js +1 -1
- package/dist/index.css +550 -550
- package/dist/index.js +45 -22
- package/dist/player.d.ts +67 -53
- package/docs/api/{player.mediacontrol.putelement.md → player.clips.gettext.md} +10 -23
- package/docs/api/player.clips.md +14 -0
- package/docs/api/player.md +9 -0
- package/docs/api/player.mediacontrol.md +0 -14
- package/docs/api/player.poster.md +2 -10
- package/docs/api/player.posterpluginsettings.md +16 -0
- package/docs/api/player.thumbnails._constructor_.md +50 -0
- package/docs/api/player.thumbnails.md +73 -0
- package/docs/api/player.thumbnails.render.md +18 -0
- package/docs/api/player.thumbnailspluginsettings.md +4 -4
- package/lib/plugins/bottom-gear/BottomGear.d.ts +5 -2
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +33 -9
- package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -1
- package/lib/plugins/thumbnails/Thumbnails.js +10 -11
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +1 -0
- package/package.json +5 -2
- package/src/plugins/bottom-gear/BottomGear.ts +35 -10
- package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +92 -55
- package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +4 -4
- package/src/plugins/thumbnails/Thumbnails.ts +18 -11
- package/src/plugins/thumbnails/__tests__/Thumbnails.test.ts +3 -3
- package/src/testUtils.ts +1 -0
- package/temp/player.api.json +144 -70
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@gcorevideo/player](./player.md) > [Thumbnails](./player.thumbnails.md) > [render](./player.thumbnails.render.md)
|
|
4
|
+
|
|
5
|
+
## Thumbnails.render() method
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
**Signature:**
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
render(): this;
|
|
14
|
+
```
|
|
15
|
+
**Returns:**
|
|
16
|
+
|
|
17
|
+
this
|
|
18
|
+
|
|
@@ -13,10 +13,10 @@ Plugin configuration options for the thumbnails plugin.
|
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
export type ThumbnailsPluginSettings = {
|
|
16
|
-
backdropHeight
|
|
17
|
-
backdropMaxOpacity
|
|
18
|
-
backdropMinOpacity
|
|
19
|
-
spotlightHeight
|
|
16
|
+
backdropHeight?: number;
|
|
17
|
+
backdropMaxOpacity?: number;
|
|
18
|
+
backdropMinOpacity?: number;
|
|
19
|
+
spotlightHeight?: number;
|
|
20
20
|
sprite: string;
|
|
21
21
|
vtt: string;
|
|
22
22
|
};
|
|
@@ -82,6 +82,8 @@ export declare enum GearEvents {
|
|
|
82
82
|
*/
|
|
83
83
|
export declare class BottomGear extends UICorePlugin {
|
|
84
84
|
private hd;
|
|
85
|
+
private numItems;
|
|
86
|
+
private collapsed;
|
|
85
87
|
/**
|
|
86
88
|
* @internal
|
|
87
89
|
*/
|
|
@@ -149,9 +151,10 @@ export declare class BottomGear extends UICorePlugin {
|
|
|
149
151
|
* Should be called by the UI plugin that added a gear item with a submenu when the latter is closed (e.g., when a "back" button is clicked).
|
|
150
152
|
*/
|
|
151
153
|
refresh(): void;
|
|
152
|
-
private
|
|
153
|
-
private
|
|
154
|
+
private toggleMenu;
|
|
155
|
+
private collapse;
|
|
154
156
|
private onCoreReady;
|
|
155
157
|
private onMediaControlRendered;
|
|
158
|
+
private mount;
|
|
156
159
|
}
|
|
157
160
|
//# sourceMappingURL=BottomGear.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomGear.d.ts","sourceRoot":"","sources":["../../../src/plugins/bottom-gear/BottomGear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuC,MAAM,cAAc,CAAA;AAOhF,OAAO,uCAAuC,CAAA;AAC9C,OAAO,gDAAgD,CAAA;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAO5C;;;GAGG;AACH,oBAAY,UAAU;IACpB;;OAEG;IACH,QAAQ,aAAa;CACtB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,EAAE,CAAQ;IAElB;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED;;OAEG;IACH,MAAM,KAAK,OAAO,WAEjB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAEvD;;OAEG;IACH,IAAa,UAAU;;MAItB;IAED;;OAEG;IACH,IAAa,MAAM;;MAIlB;IAED;;OAEG;IACM,UAAU;IASnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW;
|
|
1
|
+
{"version":3,"file":"BottomGear.d.ts","sourceRoot":"","sources":["../../../src/plugins/bottom-gear/BottomGear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuC,MAAM,cAAc,CAAA;AAOhF,OAAO,uCAAuC,CAAA;AAC9C,OAAO,gDAAgD,CAAA;AAGvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAO5C;;;GAGG;AACH,oBAAY,UAAU;IACpB;;OAEG;IACH,QAAQ,aAAa;CACtB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,EAAE,CAAQ;IAElB,OAAO,CAAC,QAAQ,CAAK;IAErB,OAAO,CAAC,SAAS,CAAQ;IAEzB;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,gBAAgB;;MAEnB;IAED;;OAEG;IACH,MAAM,KAAK,OAAO,WAEjB;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAEvD;;OAEG;IACH,IAAa,UAAU;;MAItB;IAED;;OAEG;IACH,IAAa,MAAM;;MAIlB;IAED;;OAEG;IACM,UAAU;IASnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW;IA6B1D,OAAO,CAAC,wBAAwB;IAKhC,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,oBAAoB;IAM5B;;OAEG;IACM,MAAM;IAsBf;;;;OAIG;IACH,OAAO;IAKP,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,KAAK;CAOd"}
|
|
@@ -92,6 +92,8 @@ export var GearEvents;
|
|
|
92
92
|
*/
|
|
93
93
|
export class BottomGear extends UICorePlugin {
|
|
94
94
|
hd = false;
|
|
95
|
+
numItems = 0;
|
|
96
|
+
collapsed = true;
|
|
95
97
|
/**
|
|
96
98
|
* @internal
|
|
97
99
|
*/
|
|
@@ -124,7 +126,7 @@ export class BottomGear extends UICorePlugin {
|
|
|
124
126
|
*/
|
|
125
127
|
get events() {
|
|
126
128
|
return {
|
|
127
|
-
'click #gear-button': '
|
|
129
|
+
'click #gear-button': 'toggleMenu',
|
|
128
130
|
};
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
@@ -178,6 +180,10 @@ export class BottomGear extends UICorePlugin {
|
|
|
178
180
|
this.$el.find('#gear-options').hide();
|
|
179
181
|
});
|
|
180
182
|
}
|
|
183
|
+
this.numItems++;
|
|
184
|
+
if (this.numItems > 0) {
|
|
185
|
+
this.$el.show();
|
|
186
|
+
}
|
|
181
187
|
return $item;
|
|
182
188
|
}
|
|
183
189
|
onActiveContainerChanged() {
|
|
@@ -191,7 +197,7 @@ export class BottomGear extends UICorePlugin {
|
|
|
191
197
|
highDefinitionUpdate(isHd) {
|
|
192
198
|
trace(`${T} highDefinitionUpdate`, { isHd });
|
|
193
199
|
this.hd = isHd;
|
|
194
|
-
this.$el.find('
|
|
200
|
+
this.$el.find('#gear-button').html(isHd ? gearHdIcon : gearIcon);
|
|
195
201
|
}
|
|
196
202
|
/**
|
|
197
203
|
* @internal
|
|
@@ -203,11 +209,13 @@ export class BottomGear extends UICorePlugin {
|
|
|
203
209
|
return this; // TODO test
|
|
204
210
|
}
|
|
205
211
|
const icon = this.hd ? gearHdIcon : gearIcon;
|
|
212
|
+
this.collapsed = true;
|
|
213
|
+
this.numItems = 0;
|
|
206
214
|
this.$el
|
|
207
215
|
.html(BottomGear.template({ icon }))
|
|
208
|
-
.
|
|
216
|
+
.hide() // until numItems > 0
|
|
217
|
+
.find('#gear-options-wrapper')
|
|
209
218
|
.hide();
|
|
210
|
-
// TODO make non-clickable when there are no items
|
|
211
219
|
setTimeout(() => {
|
|
212
220
|
this.trigger(GearEvents.RENDERED);
|
|
213
221
|
}, 0);
|
|
@@ -222,30 +230,46 @@ export class BottomGear extends UICorePlugin {
|
|
|
222
230
|
this.$el.find('.gear-sub-menu-wrapper').hide();
|
|
223
231
|
this.$el.find('#gear-options').show();
|
|
224
232
|
}
|
|
225
|
-
|
|
233
|
+
toggleMenu() {
|
|
226
234
|
this.core
|
|
227
235
|
.getPlugin('media_control')
|
|
228
236
|
.trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name);
|
|
229
|
-
this
|
|
237
|
+
this.collapsed = !this.collapsed;
|
|
238
|
+
if (this.collapsed) {
|
|
239
|
+
this.$el.find('#gear-options-wrapper').hide();
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
this.$el.find('#gear-options-wrapper').show();
|
|
243
|
+
}
|
|
244
|
+
this.$el.find('#gear-button').attr('aria-expanded', (!this.collapsed).toString());
|
|
245
|
+
trace(`${T} toggleMenu`, { hidden: this.collapsed });
|
|
230
246
|
}
|
|
231
|
-
|
|
247
|
+
collapse() {
|
|
232
248
|
trace(`${T} hide`);
|
|
249
|
+
this.collapsed = true;
|
|
233
250
|
this.$el.find('#gear-options-wrapper').hide();
|
|
251
|
+
this.$el.find('#gear-button').attr('aria-expanded', 'false');
|
|
234
252
|
}
|
|
235
253
|
onCoreReady() {
|
|
236
254
|
trace(`${T} onCoreReady`);
|
|
237
255
|
const mediaControl = this.core.getPlugin('media_control');
|
|
238
256
|
assert(mediaControl, 'media_control plugin is required');
|
|
239
257
|
this.listenTo(mediaControl, ClapprEvents.MEDIACONTROL_RENDERED, this.onMediaControlRendered);
|
|
240
|
-
this.listenTo(mediaControl, ClapprEvents.MEDIACONTROL_HIDE, this.
|
|
258
|
+
this.listenTo(mediaControl, ClapprEvents.MEDIACONTROL_HIDE, this.collapse);
|
|
241
259
|
this.listenTo(mediaControl, ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, (from) => {
|
|
242
260
|
if (from !== this.name) {
|
|
243
|
-
this.
|
|
261
|
+
this.collapse();
|
|
244
262
|
}
|
|
245
263
|
});
|
|
246
264
|
}
|
|
247
265
|
onMediaControlRendered() {
|
|
248
266
|
trace(`${T} onMediaControlRendered`);
|
|
267
|
+
this.mount();
|
|
268
|
+
}
|
|
269
|
+
mount() {
|
|
270
|
+
trace(`${T} mount`, {
|
|
271
|
+
numItems: this.numItems,
|
|
272
|
+
});
|
|
249
273
|
const mediaControl = this.core.getPlugin('media_control');
|
|
250
274
|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IAAI;IAaZ,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,cAAc;IAuEtB,OAAO,CAAC,oBAAoB;IAkD5B,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,WAAW;IAgBnB,OAAO,KAAK,YAAY,GAMvB;IAEQ,MAAM;CAShB"}
|
|
@@ -169,16 +169,16 @@ export class Thumbnails extends UICorePlugin {
|
|
|
169
169
|
this.update();
|
|
170
170
|
}
|
|
171
171
|
mount() {
|
|
172
|
-
// insert after the background TODO figure out why
|
|
173
172
|
const mediaControl = this.core.getPlugin('media_control');
|
|
174
|
-
mediaControl.$el.find('.seek-time').css('bottom', 56); // TODO check
|
|
175
|
-
|
|
176
|
-
mediaControl.$el.append(this.$el);
|
|
173
|
+
mediaControl.$el.find('.seek-time').css('bottom', 56); // TODO check the offset
|
|
174
|
+
mediaControl.$el.first().after(this.$el);
|
|
177
175
|
}
|
|
178
176
|
onMouseMoveSeekbar(_, pos) {
|
|
179
|
-
this.hoverPosition
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
if (Math.abs(pos - this.hoverPosition) >= 0.01) {
|
|
178
|
+
this.hoverPosition = pos;
|
|
179
|
+
this.showing = true;
|
|
180
|
+
this.update();
|
|
181
|
+
}
|
|
182
182
|
}
|
|
183
183
|
onMouseLeave() {
|
|
184
184
|
this.showing = false;
|
|
@@ -186,9 +186,9 @@ export class Thumbnails extends UICorePlugin {
|
|
|
186
186
|
}
|
|
187
187
|
// builds a dom element which represents the thumbnail
|
|
188
188
|
// scaled to the given height
|
|
189
|
-
buildThumbImage(thumb, height) {
|
|
189
|
+
buildThumbImage(thumb, height, $ref) {
|
|
190
190
|
const scaleFactor = height / thumb.h;
|
|
191
|
-
const $container = $('<div />').addClass('thumbnail-container');
|
|
191
|
+
const $container = $ref && $ref.length ? $ref : $('<div />').addClass('thumbnail-container');
|
|
192
192
|
$container.css('width', thumb.w * scaleFactor);
|
|
193
193
|
$container.css('height', height);
|
|
194
194
|
$container.css({
|
|
@@ -292,8 +292,7 @@ export class Thumbnails extends UICorePlugin {
|
|
|
292
292
|
const thumb = this.thumbs[thumbIndex];
|
|
293
293
|
// update thumbnail
|
|
294
294
|
const $spotlight = this.$el.find('#thumbnails-spotlight');
|
|
295
|
-
$spotlight.
|
|
296
|
-
$spotlight.append(this.buildThumbImage(thumb, this.spotlightHeight));
|
|
295
|
+
this.buildThumbImage(thumb, this.spotlightHeight, $spotlight.find('.thumbnail-container')).appendTo($spotlight);
|
|
297
296
|
const elWidth = this.$el.width();
|
|
298
297
|
const thumbWidth = $spotlight.width();
|
|
299
298
|
const thumbHeight = $spotlight.height();
|
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;;;;;;;;;;;;;;;;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,
|
|
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
|
@@ -109,6 +109,7 @@ export function createMockMediaControl(core) {
|
|
|
109
109
|
// @ts-ignore
|
|
110
110
|
mediaControl.toggleElement = vi.fn();
|
|
111
111
|
vi.spyOn(mediaControl, 'trigger');
|
|
112
|
+
core.$el.append(mediaControl.$el);
|
|
112
113
|
return mediaControl;
|
|
113
114
|
}
|
|
114
115
|
export function createMockBottomGear(core) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gcorevideo/player",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.2",
|
|
4
4
|
"description": "Gcore JavaScript video player",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
|
-
"keywords": [
|
|
8
|
+
"keywords": [
|
|
9
|
+
"player",
|
|
10
|
+
"video streaming"
|
|
11
|
+
],
|
|
9
12
|
"scripts": {
|
|
10
13
|
"build": "npm run build:ts && npm run build:bundle",
|
|
11
14
|
"build:1": "npm run build:ts && npm run build:bundle && date",
|
|
@@ -100,6 +100,10 @@ export enum GearEvents {
|
|
|
100
100
|
export class BottomGear extends UICorePlugin {
|
|
101
101
|
private hd = false
|
|
102
102
|
|
|
103
|
+
private numItems = 0;
|
|
104
|
+
|
|
105
|
+
private collapsed = true;
|
|
106
|
+
|
|
103
107
|
/**
|
|
104
108
|
* @internal
|
|
105
109
|
*/
|
|
@@ -137,7 +141,7 @@ export class BottomGear extends UICorePlugin {
|
|
|
137
141
|
*/
|
|
138
142
|
override get events() {
|
|
139
143
|
return {
|
|
140
|
-
'click #gear-button': '
|
|
144
|
+
'click #gear-button': 'toggleMenu',
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
|
|
@@ -197,6 +201,10 @@ export class BottomGear extends UICorePlugin {
|
|
|
197
201
|
this.$el.find('#gear-options').hide()
|
|
198
202
|
})
|
|
199
203
|
}
|
|
204
|
+
this.numItems++;
|
|
205
|
+
if (this.numItems > 0) {
|
|
206
|
+
this.$el.show()
|
|
207
|
+
}
|
|
200
208
|
return $item
|
|
201
209
|
}
|
|
202
210
|
|
|
@@ -217,7 +225,7 @@ export class BottomGear extends UICorePlugin {
|
|
|
217
225
|
private highDefinitionUpdate(isHd: boolean) {
|
|
218
226
|
trace(`${T} highDefinitionUpdate`, { isHd })
|
|
219
227
|
this.hd = isHd
|
|
220
|
-
this.$el.find('
|
|
228
|
+
this.$el.find('#gear-button').html(isHd ? gearHdIcon : gearIcon)
|
|
221
229
|
}
|
|
222
230
|
|
|
223
231
|
/**
|
|
@@ -230,13 +238,14 @@ export class BottomGear extends UICorePlugin {
|
|
|
230
238
|
return this // TODO test
|
|
231
239
|
}
|
|
232
240
|
const icon = this.hd ? gearHdIcon : gearIcon
|
|
241
|
+
this.collapsed = true;
|
|
242
|
+
this.numItems = 0;
|
|
233
243
|
this.$el
|
|
234
244
|
.html(BottomGear.template({ icon }))
|
|
235
|
-
.
|
|
245
|
+
.hide() // until numItems > 0
|
|
246
|
+
.find('#gear-options-wrapper')
|
|
236
247
|
.hide()
|
|
237
248
|
|
|
238
|
-
// TODO make non-clickable when there are no items
|
|
239
|
-
|
|
240
249
|
setTimeout(() => {
|
|
241
250
|
this.trigger(GearEvents.RENDERED)
|
|
242
251
|
}, 0)
|
|
@@ -254,16 +263,25 @@ export class BottomGear extends UICorePlugin {
|
|
|
254
263
|
this.$el.find('#gear-options').show()
|
|
255
264
|
}
|
|
256
265
|
|
|
257
|
-
private
|
|
266
|
+
private toggleMenu() {
|
|
258
267
|
this.core
|
|
259
268
|
.getPlugin('media_control')
|
|
260
269
|
.trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name)
|
|
261
|
-
this
|
|
270
|
+
this.collapsed = !this.collapsed;
|
|
271
|
+
if (this.collapsed) {
|
|
272
|
+
this.$el.find('#gear-options-wrapper').hide()
|
|
273
|
+
} else {
|
|
274
|
+
this.$el.find('#gear-options-wrapper').show()
|
|
275
|
+
}
|
|
276
|
+
this.$el.find('#gear-button').attr('aria-expanded', (!this.collapsed).toString())
|
|
277
|
+
trace(`${T} toggleMenu`, { hidden: this.collapsed })
|
|
262
278
|
}
|
|
263
279
|
|
|
264
|
-
private
|
|
280
|
+
private collapse() {
|
|
265
281
|
trace(`${T} hide`)
|
|
282
|
+
this.collapsed = true;
|
|
266
283
|
this.$el.find('#gear-options-wrapper').hide()
|
|
284
|
+
this.$el.find('#gear-button').attr('aria-expanded', 'false')
|
|
267
285
|
}
|
|
268
286
|
|
|
269
287
|
private onCoreReady() {
|
|
@@ -275,13 +293,13 @@ export class BottomGear extends UICorePlugin {
|
|
|
275
293
|
ClapprEvents.MEDIACONTROL_RENDERED,
|
|
276
294
|
this.onMediaControlRendered,
|
|
277
295
|
)
|
|
278
|
-
this.listenTo(mediaControl, ClapprEvents.MEDIACONTROL_HIDE, this.
|
|
296
|
+
this.listenTo(mediaControl, ClapprEvents.MEDIACONTROL_HIDE, this.collapse)
|
|
279
297
|
this.listenTo(
|
|
280
298
|
mediaControl,
|
|
281
299
|
ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE,
|
|
282
300
|
(from: string) => {
|
|
283
301
|
if (from !== this.name) {
|
|
284
|
-
this.
|
|
302
|
+
this.collapse()
|
|
285
303
|
}
|
|
286
304
|
},
|
|
287
305
|
)
|
|
@@ -289,6 +307,13 @@ export class BottomGear extends UICorePlugin {
|
|
|
289
307
|
|
|
290
308
|
private onMediaControlRendered() {
|
|
291
309
|
trace(`${T} onMediaControlRendered`)
|
|
310
|
+
this.mount()
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private mount() {
|
|
314
|
+
trace(`${T} mount`, {
|
|
315
|
+
numItems: this.numItems,
|
|
316
|
+
})
|
|
292
317
|
const mediaControl = this.core.getPlugin('media_control')
|
|
293
318
|
mediaControl.mount('gear', this.$el)
|
|
294
319
|
}
|
|
@@ -5,6 +5,11 @@ import { createMockCore, createMockMediaControl } from '../../../testUtils'
|
|
|
5
5
|
import { Events } from '@clappr/core'
|
|
6
6
|
import { ExtendedEvents } from '../../media-control/MediaControl'
|
|
7
7
|
|
|
8
|
+
// import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
|
|
9
|
+
|
|
10
|
+
// Logger.enable('*')
|
|
11
|
+
// setTracer(new LogTracer('BottomGear.test'))
|
|
12
|
+
|
|
8
13
|
describe('BottomGear', () => {
|
|
9
14
|
let mediaControl: any
|
|
10
15
|
let core: any
|
|
@@ -12,72 +17,104 @@ describe('BottomGear', () => {
|
|
|
12
17
|
let onGearRendered: MockedFunction<() => void>
|
|
13
18
|
beforeEach(() => {
|
|
14
19
|
core = createMockCore()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
bottomGear = new BottomGear(core)
|
|
22
|
-
onGearRendered = vi.fn()
|
|
23
|
-
bottomGear.on(GearEvents.RENDERED, onGearRendered, null)
|
|
24
|
-
bottomGear.render()
|
|
25
|
-
core.emit(Events.CORE_READY)
|
|
26
|
-
})
|
|
27
|
-
it('should render', () => {
|
|
28
|
-
expect(bottomGear.el.innerHTML).toMatchSnapshot()
|
|
29
|
-
})
|
|
30
|
-
it('should emit event in the next cycle', async () => {
|
|
31
|
-
expect(onGearRendered).not.toHaveBeenCalled()
|
|
32
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
33
|
-
expect(onGearRendered).toHaveBeenCalled()
|
|
34
|
-
})
|
|
35
|
-
it('should render the gear menu hidden', () => {
|
|
36
|
-
expect(bottomGear.$el.find('#gear-options-wrapper').css('display')).toBe(
|
|
37
|
-
'none',
|
|
38
|
-
)
|
|
20
|
+
mediaControl = createMockMediaControl(core)
|
|
21
|
+
core.getPlugin = vi
|
|
22
|
+
.fn()
|
|
23
|
+
.mockImplementation((name) =>
|
|
24
|
+
name === 'media_control' ? mediaControl : null,
|
|
25
|
+
)
|
|
39
26
|
})
|
|
40
|
-
describe('
|
|
41
|
-
it('should not attach to media control', () => {
|
|
42
|
-
expect(mediaControl.mount).not.toHaveBeenCalledWith(
|
|
43
|
-
'gear',
|
|
44
|
-
expect.anything(),
|
|
45
|
-
)
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
describe('when media control is rendered', () => {
|
|
27
|
+
describe('basically', () => {
|
|
49
28
|
beforeEach(() => {
|
|
50
|
-
|
|
29
|
+
bottomGear = new BottomGear(core)
|
|
30
|
+
onGearRendered = vi.fn()
|
|
31
|
+
bottomGear.on(GearEvents.RENDERED, onGearRendered, null)
|
|
32
|
+
bottomGear.render()
|
|
33
|
+
core.emit(Events.CORE_READY)
|
|
34
|
+
bottomGear.addItem('test', null).html('<button>test</button>')
|
|
51
35
|
})
|
|
52
|
-
it('should
|
|
53
|
-
expect(
|
|
36
|
+
it('should render', () => {
|
|
37
|
+
expect(bottomGear.el.innerHTML).toMatchSnapshot()
|
|
54
38
|
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
it('should render the gear menu hidden', () => {
|
|
40
|
+
expect(bottomGear.$el.find('#gear-options-wrapper').css('display')).toBe(
|
|
41
|
+
'none',
|
|
42
|
+
)
|
|
59
43
|
})
|
|
60
|
-
it('should
|
|
61
|
-
expect(
|
|
62
|
-
|
|
63
|
-
).
|
|
44
|
+
it('should emit event in the next render cycle', async () => {
|
|
45
|
+
expect(onGearRendered).not.toHaveBeenCalled()
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
47
|
+
expect(onGearRendered).toHaveBeenCalled()
|
|
64
48
|
})
|
|
65
|
-
it('should
|
|
66
|
-
expect(
|
|
67
|
-
|
|
68
|
-
'bottom_gear',
|
|
49
|
+
it('should render the gear menu hidden', () => {
|
|
50
|
+
expect(bottomGear.$el.find('#gear-options-wrapper').css('display')).toBe(
|
|
51
|
+
'none',
|
|
69
52
|
)
|
|
70
53
|
})
|
|
54
|
+
describe('until media control is rendered', () => {
|
|
55
|
+
it('should not attach to media control', () => {
|
|
56
|
+
expect(mediaControl.mount).not.toHaveBeenCalledWith(
|
|
57
|
+
'gear',
|
|
58
|
+
expect.anything(),
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
describe('when media control is rendered', () => {
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
mediaControl.trigger(Events.MEDIACONTROL_RENDERED)
|
|
65
|
+
})
|
|
66
|
+
it('should attach to media control', () => {
|
|
67
|
+
expect(mediaControl.mount).toHaveBeenCalledWith('gear', bottomGear.$el)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
describe('when clicked', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
bottomGear.$el.find('#gear-button').click()
|
|
73
|
+
})
|
|
74
|
+
it('should open the gear menu', () => {
|
|
75
|
+
expect(
|
|
76
|
+
bottomGear.$el.find('#gear-options-wrapper').css('display'),
|
|
77
|
+
).not.toBe('none')
|
|
78
|
+
expect(bottomGear.$el.find('#gear-button').attr('aria-expanded')).toBe(
|
|
79
|
+
'true',
|
|
80
|
+
)
|
|
81
|
+
})
|
|
82
|
+
it('should trigger media control menu collapse', () => {
|
|
83
|
+
expect(mediaControl.trigger).toHaveBeenCalledWith(
|
|
84
|
+
ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE,
|
|
85
|
+
'bottom_gear',
|
|
86
|
+
)
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
describe('when clicked twice', () => {
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
bottomGear.$el.find('#gear-button').click()
|
|
92
|
+
bottomGear.$el.find('#gear-button').click()
|
|
93
|
+
})
|
|
94
|
+
it('should collapse the gear menu', () => {
|
|
95
|
+
expect(bottomGear.$el.find('#gear-options-wrapper').css('display')).toBe(
|
|
96
|
+
'none',
|
|
97
|
+
)
|
|
98
|
+
expect(bottomGear.$el.find('#gear-button').attr('aria-expanded')).toBe(
|
|
99
|
+
'false',
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
71
103
|
})
|
|
72
|
-
describe('when
|
|
104
|
+
describe('when there are no items', () => {
|
|
73
105
|
beforeEach(() => {
|
|
74
|
-
bottomGear
|
|
75
|
-
|
|
106
|
+
bottomGear = new BottomGear(core)
|
|
107
|
+
onGearRendered = vi.fn()
|
|
108
|
+
bottomGear.on(GearEvents.RENDERED, onGearRendered, null)
|
|
109
|
+
bottomGear.render()
|
|
110
|
+
core.emit(Events.CORE_READY)
|
|
76
111
|
})
|
|
77
|
-
it('should
|
|
78
|
-
expect(bottomGear.$el.
|
|
79
|
-
|
|
80
|
-
|
|
112
|
+
it('should render hidden', () => {
|
|
113
|
+
expect(bottomGear.$el.css('display')).toBe('none')
|
|
114
|
+
})
|
|
115
|
+
it('should show button after item is added', () => {
|
|
116
|
+
bottomGear.addItem('test', null).html('<button>test</button>')
|
|
117
|
+
expect(bottomGear.$el.css('display')).not.toBe('none')
|
|
81
118
|
})
|
|
82
119
|
})
|
|
83
120
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`BottomGear > should render 1`] = `
|
|
4
|
-
"<button class="media-control-button gplayer-lite-btn gcore-skin-button-color gear-icon" id="gear-button">
|
|
3
|
+
exports[`BottomGear > basically > should render 1`] = `
|
|
4
|
+
"<button class="media-control-button gplayer-lite-btn gcore-skin-button-color gear-icon" id="gear-button" aria-expanded="false" aria-controls="gear-options">
|
|
5
5
|
/assets/icons/new/gear.svg
|
|
6
6
|
</button>
|
|
7
|
-
<div class="gear-wrapper gcore-skin-bg-color" id="gear-options-wrapper" style="display:none">
|
|
8
|
-
<ul class="gear-options-list" id="gear-options" role="menu"></ul>
|
|
7
|
+
<div class="gear-wrapper gcore-skin-bg-color" id="gear-options-wrapper" style="display: none;">
|
|
8
|
+
<ul class="gear-options-list" id="gear-options" role="menu"><li data-test=""><button>test</button></li></ul>
|
|
9
9
|
</div>
|
|
10
10
|
"
|
|
11
11
|
`;
|
|
@@ -255,17 +255,17 @@ export class Thumbnails extends UICorePlugin {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
private mount() {
|
|
258
|
-
// insert after the background TODO figure out why
|
|
259
258
|
const mediaControl = this.core.getPlugin('media_control') as MediaControl
|
|
260
|
-
mediaControl.$el.find('.seek-time').css('bottom', 56) // TODO check
|
|
261
|
-
|
|
262
|
-
mediaControl.$el.append(this.$el)
|
|
259
|
+
mediaControl.$el.find('.seek-time').css('bottom', 56) // TODO check the offset
|
|
260
|
+
mediaControl.$el.first().after(this.$el);
|
|
263
261
|
}
|
|
264
262
|
|
|
265
263
|
private onMouseMoveSeekbar(_: MouseEvent, pos: number) {
|
|
266
|
-
this.hoverPosition
|
|
267
|
-
|
|
268
|
-
|
|
264
|
+
if (Math.abs(pos - this.hoverPosition) >= 0.01) {
|
|
265
|
+
this.hoverPosition = pos
|
|
266
|
+
this.showing = true
|
|
267
|
+
this.update()
|
|
268
|
+
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
private onMouseLeave() {
|
|
@@ -275,9 +275,13 @@ export class Thumbnails extends UICorePlugin {
|
|
|
275
275
|
|
|
276
276
|
// builds a dom element which represents the thumbnail
|
|
277
277
|
// scaled to the given height
|
|
278
|
-
private buildThumbImage(
|
|
278
|
+
private buildThumbImage(
|
|
279
|
+
thumb: ThumbnailDesc,
|
|
280
|
+
height: number,
|
|
281
|
+
$ref?: ZeptoResult,
|
|
282
|
+
) {
|
|
279
283
|
const scaleFactor = height / thumb.h
|
|
280
|
-
const $container = $('<div />').addClass('thumbnail-container')
|
|
284
|
+
const $container = $ref && $ref.length ? $ref : $('<div />').addClass('thumbnail-container')
|
|
281
285
|
|
|
282
286
|
$container.css('width', thumb.w * scaleFactor)
|
|
283
287
|
$container.css('height', height)
|
|
@@ -414,8 +418,11 @@ export class Thumbnails extends UICorePlugin {
|
|
|
414
418
|
// update thumbnail
|
|
415
419
|
const $spotlight = this.$el.find('#thumbnails-spotlight')
|
|
416
420
|
|
|
417
|
-
|
|
418
|
-
|
|
421
|
+
this.buildThumbImage(
|
|
422
|
+
thumb,
|
|
423
|
+
this.spotlightHeight,
|
|
424
|
+
$spotlight.find('.thumbnail-container'),
|
|
425
|
+
).appendTo($spotlight)
|
|
419
426
|
|
|
420
427
|
const elWidth = this.$el.width()
|
|
421
428
|
const thumbWidth = $spotlight.width()
|
|
@@ -55,14 +55,14 @@ sprite.png#xywh=200,200,100,100
|
|
|
55
55
|
it('should render', () => {
|
|
56
56
|
expect(thumbnails.$el.html()).toMatchSnapshot()
|
|
57
57
|
})
|
|
58
|
-
it('should mount
|
|
59
|
-
expect(
|
|
58
|
+
it('should mount along with media controls', () => {
|
|
59
|
+
expect(core.$el.find('.scrub-thumbnails')).toHaveLength(1)
|
|
60
60
|
})
|
|
61
61
|
it('should load image dimensions', () => {
|
|
62
62
|
expect(loadImageDimensions).toHaveBeenCalledWith('https://example.com/sprite.png')
|
|
63
63
|
})
|
|
64
64
|
it('should parse sprite sheet and create thumbnails', () => {
|
|
65
|
-
const thumbs =
|
|
65
|
+
const thumbs = thumbnails.$el.find('#thumbnails-carousel .thumbnail-container')
|
|
66
66
|
expect(thumbs).toHaveLength(2)
|
|
67
67
|
})
|
|
68
68
|
it('should hide', () => {
|