@gcorevideo/player 2.21.3 → 2.21.4
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/audio-selector/style.scss +1 -1
- package/assets/audio-selector/track-selector.ejs +3 -3
- package/assets/bottom-gear/bottomgear.ejs +2 -2
- package/assets/media-control/container.scss +1 -1
- package/assets/media-control/media-control.ejs +1 -6
- package/assets/media-control/media-control.scss +6 -4
- package/assets/media-control/width270.scss +1 -1
- package/assets/media-control/width370.scss +4 -4
- package/assets/playback-rate/button.ejs +2 -2
- package/assets/playback-rate/list.ejs +4 -4
- package/assets/subtitles/combobox.ejs +5 -5
- package/assets/subtitles/string.ejs +1 -1
- package/assets/subtitles/style.scss +2 -2
- package/dist/core.js +2 -1
- package/dist/index.css +972 -967
- package/dist/index.js +126 -106
- package/dist/player.d.ts +141 -119
- package/dist/plugins/index.css +801 -796
- package/dist/plugins/index.js +119 -104
- package/docs/api/player.bottomgear.getelement.md +2 -2
- package/docs/api/player.bottomgear.md +1 -1
- package/docs/api/{player.subtitles.hide.md → player.closedcaptions.hide.md} +2 -2
- package/docs/api/{player.subtitles.md → player.closedcaptions.md} +11 -11
- package/docs/api/{player.subtitles.show.md → player.closedcaptions.show.md} +2 -2
- package/docs/api/player.closedcaptionspluginsettings.md +13 -0
- package/docs/api/player.gearitemelement.md +6 -4
- package/docs/api/player.gearoptionsitem.md +16 -0
- package/docs/api/player.md +48 -12
- package/docs/api/player.mediacontrol.putelement.md +2 -2
- package/docs/api/player.mediacontrolelement.md +1 -1
- package/docs/api/player.playbackrate.md +1 -1
- package/docs/api/player.subtitlespluginsettings.md +18 -0
- package/docs/api/player.texttrackitem.id.md +11 -0
- package/docs/api/player.texttrackitem.md +87 -0
- package/docs/api/player.texttrackitem.name.md +11 -0
- package/docs/api/player.texttrackitem.track.md +11 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.plugins.d.ts +2 -1
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +2 -1
- package/lib/playback/dash-playback/DashPlayback.d.ts.map +1 -1
- package/lib/playback/dash-playback/DashPlayback.js +1 -0
- package/lib/plugins/audio-selector/AudioSelector.d.ts +2 -3
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +6 -7
- package/lib/plugins/bottom-gear/BottomGear.d.ts +6 -2
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +2 -1
- package/lib/plugins/media-control/MediaControl.d.ts +5 -5
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +46 -39
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +1 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
- package/lib/plugins/picture-in-picture/PictureInPicture.js +4 -4
- package/lib/plugins/playback-rate/PlaybackRate.d.ts +0 -1
- package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -1
- package/lib/plugins/playback-rate/PlaybackRate.js +23 -14
- package/lib/plugins/subtitles/ClosedCaptions.d.ts +118 -0
- package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -0
- package/lib/plugins/subtitles/ClosedCaptions.js +348 -0
- package/lib/plugins/subtitles/Subtitles.d.ts +12 -9
- package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -1
- package/lib/plugins/subtitles/Subtitles.js +31 -32
- package/lib/testUtils.d.ts +22 -18
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +22 -36
- package/package.json +1 -1
- package/src/index.plugins.ts +2 -1
- package/src/index.ts +1 -1
- package/src/playback/dash-playback/DashPlayback.ts +1 -0
- package/src/plugins/audio-selector/AudioSelector.ts +9 -8
- package/src/plugins/bottom-gear/BottomGear.ts +11 -4
- package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +1 -1
- package/src/plugins/bottom-gear/__tests__/__snapshots__/BottomGear.test.ts.snap +2 -2
- package/src/plugins/media-control/MediaControl.ts +53 -46
- package/src/plugins/media-control/__tests__/MediaControl.test.ts +43 -0
- package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +175 -0
- package/src/plugins/picture-in-picture/PictureInPicture.ts +5 -5
- package/src/plugins/playback-rate/PlaybackRate.ts +142 -100
- package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +65 -0
- package/src/plugins/playback-rate/__tests__/__snapshots__/PlaybackRate.test.ts.snap +11 -0
- package/src/plugins/subtitles/{Subtitles.ts → ClosedCaptions.ts} +42 -34
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +58 -0
- package/src/plugins/subtitles/__tests__/__snapshots__/ClosedCaptions.test.ts.snap +25 -0
- package/src/testUtils.ts +22 -36
- package/temp/player.api.json +269 -89
- package/tsconfig.tsbuildinfo +1 -1
- package/src/plugins/index.ts +0 -39
package/lib/testUtils.js
CHANGED
|
@@ -98,47 +98,31 @@ export function createMockPlayback(name = 'mock') {
|
|
|
98
98
|
return Object.assign(emitter, {
|
|
99
99
|
name,
|
|
100
100
|
currentLevel: -1,
|
|
101
|
+
dvrEnabled: false,
|
|
101
102
|
levels: [],
|
|
102
103
|
consent() { },
|
|
103
104
|
play() { },
|
|
104
105
|
pause() { },
|
|
105
106
|
stop() { },
|
|
106
|
-
destroy()
|
|
107
|
-
seek()
|
|
108
|
-
seekPercentage()
|
|
109
|
-
getDuration()
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
mute() { },
|
|
127
|
-
unmute() { },
|
|
128
|
-
volume() { },
|
|
129
|
-
configure() { },
|
|
130
|
-
attemptAutoPlay() {
|
|
131
|
-
return true;
|
|
132
|
-
},
|
|
133
|
-
canAutoPlay() {
|
|
134
|
-
return true;
|
|
135
|
-
},
|
|
136
|
-
onResize() {
|
|
137
|
-
return true;
|
|
138
|
-
},
|
|
139
|
-
trigger(event, ...args) {
|
|
140
|
-
emitter.emit(event, ...args);
|
|
141
|
-
},
|
|
107
|
+
destroy: vi.fn(),
|
|
108
|
+
seek: vi.fn(),
|
|
109
|
+
seekPercentage: vi.fn(),
|
|
110
|
+
getDuration: vi.fn().mockImplementation(() => 100),
|
|
111
|
+
enterPiP: vi.fn(),
|
|
112
|
+
exitPiP: vi.fn(),
|
|
113
|
+
getPlaybackType: vi.fn().mockImplementation(() => 'live'),
|
|
114
|
+
getStartTimeOffset: vi.fn().mockImplementation(() => 0),
|
|
115
|
+
getCurrentTime: vi.fn().mockImplementation(() => 0),
|
|
116
|
+
isHighDefinitionInUse: vi.fn().mockImplementation(() => false),
|
|
117
|
+
mute: vi.fn(),
|
|
118
|
+
unmute: vi.fn(),
|
|
119
|
+
volume: vi.fn(),
|
|
120
|
+
configure: vi.fn(),
|
|
121
|
+
attemptAutoPlay: vi.fn().mockImplementation(() => true),
|
|
122
|
+
canAutoPlay: vi.fn().mockImplementation(() => true),
|
|
123
|
+
onResize: vi.fn().mockImplementation(() => true),
|
|
124
|
+
setPlaybackRate: vi.fn(),
|
|
125
|
+
trigger: emitter.emit,
|
|
142
126
|
});
|
|
143
127
|
}
|
|
144
128
|
export function createMockContainer(playback = createMockPlayback()) {
|
|
@@ -150,6 +134,8 @@ export function createMockContainer(playback = createMockPlayback()) {
|
|
|
150
134
|
$el: $(el),
|
|
151
135
|
getDuration: vi.fn().mockReturnValue(0),
|
|
152
136
|
getPlugin: vi.fn(),
|
|
137
|
+
getPlaybackType: vi.fn().mockReturnValue('live'),
|
|
138
|
+
isDvrInUse: vi.fn().mockReturnValue(false),
|
|
153
139
|
isPlaying: vi.fn().mockReturnValue(false),
|
|
154
140
|
play: vi.fn(),
|
|
155
141
|
seek: vi.fn(),
|
package/package.json
CHANGED
package/src/index.plugins.ts
CHANGED
|
@@ -25,7 +25,8 @@ export * from "./plugins/share/Share.js";
|
|
|
25
25
|
export * from "./plugins/skip-time/SkipTime.js";
|
|
26
26
|
export * from "./plugins/spinner-three-bounce/SpinnerThreeBounce.js";
|
|
27
27
|
export * from "./plugins/source-controller/SourceController.js";
|
|
28
|
-
export * from "./plugins/subtitles/
|
|
28
|
+
export * from "./plugins/subtitles/ClosedCaptions.js";
|
|
29
|
+
export { ClosedCaptions as Subtitles } from "./plugins/subtitles/ClosedCaptions.js"; // TODO remove in future versions
|
|
29
30
|
export * from "./plugins/telemetry/Telemetry.js";
|
|
30
31
|
export * from "./plugins/thumbnails/Thumbnails.js";
|
|
31
32
|
// _ vast-ads
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
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
7
|
* Start with {@link Player} for more information.
|
|
8
8
|
*
|
|
9
|
-
* Various plugins (marked with `PLUGIN` keyword) are available to extend the
|
|
9
|
+
* Various plugins (marked with `PLUGIN` keyword) are available to extend the core functionality with additional features.
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { Player, MediaControl, ErrorScreen } from '@gcorevideo/player'
|
|
@@ -416,6 +416,7 @@ export default class DashPlayback extends BasePlayback {
|
|
|
416
416
|
this.trigger(Events.PLAYBACK_STATS_ADD, { dvr: status })
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
// TODO move to the base class
|
|
419
420
|
override _updateSettings() {
|
|
420
421
|
if (this._playbackType === Playback.VOD) {
|
|
421
422
|
// @ts-expect-error
|
|
@@ -9,6 +9,7 @@ import pluginHtml from '../../../assets/audio-selector/track-selector.ejs'
|
|
|
9
9
|
import '../../../assets/audio-selector/style.scss'
|
|
10
10
|
import audioArrow from '../../../assets/icons/old/quality-arrow.svg'
|
|
11
11
|
import { ZeptoResult } from '../../types.js'
|
|
12
|
+
import { MediaControl } from '../media-control/MediaControl.js'
|
|
12
13
|
|
|
13
14
|
const VERSION: string = '0.0.1'
|
|
14
15
|
|
|
@@ -57,8 +58,8 @@ export class AudioSelector extends UICorePlugin {
|
|
|
57
58
|
*/
|
|
58
59
|
override get attributes() {
|
|
59
60
|
return {
|
|
60
|
-
class: 'media-control-
|
|
61
|
-
|
|
61
|
+
class: 'media-control-audiotracks',
|
|
62
|
+
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -67,8 +68,8 @@ export class AudioSelector extends UICorePlugin {
|
|
|
67
68
|
*/
|
|
68
69
|
override get events() {
|
|
69
70
|
return {
|
|
70
|
-
'click [data-
|
|
71
|
-
'click [data-
|
|
71
|
+
'click [data-audiotracks-select]': 'onTrackSelect',
|
|
72
|
+
'click [data-audiotracks-button]': 'onShowLevelSelectMenu',
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -156,12 +157,12 @@ export class AudioSelector extends UICorePlugin {
|
|
|
156
157
|
return this
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
const mediaControl = this.core.getPlugin('media_control')
|
|
160
|
+
const mediaControl = this.core.getPlugin('media_control') as MediaControl
|
|
160
161
|
this.$el.html(
|
|
161
162
|
AudioSelector.template({ tracks: this.tracks, title: this.getTitle() }),
|
|
162
163
|
)
|
|
163
164
|
this.$('.audio-arrow').append(audioArrow)
|
|
164
|
-
mediaControl.putElement('
|
|
165
|
+
mediaControl.putElement('audiotracks', this.el)
|
|
165
166
|
|
|
166
167
|
this.updateText()
|
|
167
168
|
this.highlightCurrentTrack()
|
|
@@ -179,7 +180,7 @@ export class AudioSelector extends UICorePlugin {
|
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
private onTrackSelect(event: MouseEvent) {
|
|
182
|
-
const id = (event.target as HTMLElement)?.dataset?.
|
|
183
|
+
const id = (event.target as HTMLElement)?.dataset?.audiotracksSelect
|
|
183
184
|
if (id) {
|
|
184
185
|
this.selectAudioTrack(id)
|
|
185
186
|
}
|
|
@@ -218,7 +219,7 @@ export class AudioSelector extends UICorePlugin {
|
|
|
218
219
|
return (
|
|
219
220
|
this.$(
|
|
220
221
|
'ul a' +
|
|
221
|
-
(id !== undefined ? '[data-
|
|
222
|
+
(id !== undefined ? '[data-audiotracks-select="' + id + '"]' : ''),
|
|
222
223
|
) as ZeptoResult
|
|
223
224
|
).parent()
|
|
224
225
|
}
|
|
@@ -20,7 +20,12 @@ const T = 'plugins.bottom_gear';
|
|
|
20
20
|
* An element inside the gear menu
|
|
21
21
|
* @beta
|
|
22
22
|
*/
|
|
23
|
-
export type
|
|
23
|
+
export type GearOptionsItem = 'quality' | 'rate' | 'nerd';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use {@link GearOptionsItem} instead
|
|
27
|
+
*/
|
|
28
|
+
export type GearItemElement = GearOptionsItem;
|
|
24
29
|
|
|
25
30
|
// TODO disabled if no items added
|
|
26
31
|
|
|
@@ -90,10 +95,12 @@ export class BottomGear extends UICorePlugin {
|
|
|
90
95
|
* @param name - Name of a gear menu placeholder item to attach custom UI
|
|
91
96
|
* @returns Zepto result of the element
|
|
92
97
|
*/
|
|
93
|
-
getElement(name:
|
|
98
|
+
getElement(name: GearOptionsItem): ZeptoResult | null {
|
|
94
99
|
return this.$el.find(`.gear-options-list [data-${name}]`);
|
|
95
100
|
}
|
|
96
101
|
|
|
102
|
+
// TODO implement putElement/addElement method
|
|
103
|
+
|
|
97
104
|
/**
|
|
98
105
|
* Replaces the content of the gear menu
|
|
99
106
|
* @param content - Zepto result of the element
|
|
@@ -125,7 +132,7 @@ export class BottomGear extends UICorePlugin {
|
|
|
125
132
|
const mediaControl = this.core.getPlugin('media_control');
|
|
126
133
|
|
|
127
134
|
// TODO use options.mediaControl.gear.items
|
|
128
|
-
const items:
|
|
135
|
+
const items: GearOptionsItem[] = [
|
|
129
136
|
'quality',
|
|
130
137
|
'rate',
|
|
131
138
|
'nerd',
|
|
@@ -133,7 +140,7 @@ export class BottomGear extends UICorePlugin {
|
|
|
133
140
|
const icon = this.isHd ? gearHdIcon : gearIcon;
|
|
134
141
|
this.$el.html(BottomGear.template({ icon, items }));
|
|
135
142
|
|
|
136
|
-
mediaControl.putElement('gear', this
|
|
143
|
+
mediaControl.putElement('gear', this.el);
|
|
137
144
|
mediaControl.trigger(MediaControlEvents.MEDIACONTROL_GEAR_RENDERED);
|
|
138
145
|
return this;
|
|
139
146
|
}
|
|
@@ -26,7 +26,7 @@ describe('BottomGear', () => {
|
|
|
26
26
|
expect(bottomGear.el.innerHTML).toMatchSnapshot()
|
|
27
27
|
})
|
|
28
28
|
it('should attach to media control', () => {
|
|
29
|
-
expect(mediaControl.putElement).toHaveBeenCalledWith('gear', bottomGear
|
|
29
|
+
expect(mediaControl.putElement).toHaveBeenCalledWith('gear', bottomGear.el)
|
|
30
30
|
})
|
|
31
31
|
it('should emit event', () => {
|
|
32
32
|
expect(onGearRendered).toHaveBeenCalled()
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
3
|
exports[`BottomGear > should render 1`] = `
|
|
4
|
-
"<button type="button" class="button-gear media-control-button gplayer-lite-btn gcore-skin-button-color gear-icon" data-gear-button="-1">
|
|
4
|
+
"<button type="button" class="button-gear media-control-button gplayer-lite-btn gcore-skin-button-color gear-icon" data-gear-button="-1" id="gear-button">
|
|
5
5
|
/assets/icons/new/gear.svg
|
|
6
6
|
</button>
|
|
7
7
|
<div class="gear-wrapper gcore-skin-bg-color">
|
|
8
|
-
<ul class="gear-options-list">
|
|
8
|
+
<ul class="gear-options-list" id="gear-options">
|
|
9
9
|
|
|
10
10
|
<li data-quality=""></li>
|
|
11
11
|
|
|
@@ -42,13 +42,13 @@ import fullscreenOnIcon from '../../../assets/icons/new/fullscreen-on.svg'
|
|
|
42
42
|
* @beta
|
|
43
43
|
*/
|
|
44
44
|
export type MediaControlElement =
|
|
45
|
-
| '
|
|
45
|
+
| 'audiotracks'
|
|
46
46
|
| 'clipText'
|
|
47
47
|
| 'gear'
|
|
48
48
|
| 'pip'
|
|
49
49
|
| 'playbackRate'
|
|
50
50
|
| 'seekBarContainer'
|
|
51
|
-
| '
|
|
51
|
+
| 'cc'
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Custom events emitted by the plugins to communicate with one another
|
|
@@ -95,7 +95,7 @@ type DisabledClickable = {
|
|
|
95
95
|
* The methods exposed are to be used by the other plugins that extend the media control UI.
|
|
96
96
|
*/
|
|
97
97
|
export class MediaControl extends UICorePlugin {
|
|
98
|
-
private advertisementPlaying = false
|
|
98
|
+
// private advertisementPlaying = false
|
|
99
99
|
|
|
100
100
|
private buttonsColor: string | null = null
|
|
101
101
|
|
|
@@ -131,7 +131,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
131
131
|
|
|
132
132
|
private rendered = false
|
|
133
133
|
|
|
134
|
-
private settings: Record<string,
|
|
134
|
+
private settings: Record<string, MediaControlElement[]> = {} // TODO & seekEnabled: boolean, ...
|
|
135
135
|
|
|
136
136
|
private userDisabled = false
|
|
137
137
|
|
|
@@ -394,12 +394,12 @@ export class MediaControl extends UICorePlugin {
|
|
|
394
394
|
this.listenTo(
|
|
395
395
|
this.core.activeContainer,
|
|
396
396
|
Events.CONTAINER_SETTINGSUPDATE,
|
|
397
|
-
this.
|
|
397
|
+
this.updateSettings,
|
|
398
398
|
)
|
|
399
399
|
this.listenTo(
|
|
400
400
|
this.core.activeContainer,
|
|
401
401
|
Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
402
|
-
this.
|
|
402
|
+
this.updateSettings,
|
|
403
403
|
)
|
|
404
404
|
this.listenTo(
|
|
405
405
|
this.core.activeContainer,
|
|
@@ -427,14 +427,12 @@ export class MediaControl extends UICorePlugin {
|
|
|
427
427
|
Events.CONTAINER_OPTIONS_CHANGE,
|
|
428
428
|
this.setInitialVolume,
|
|
429
429
|
)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
this.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
)
|
|
437
|
-
}
|
|
430
|
+
// wait until the metadata has loaded and then check if fullscreen on video tag is supported
|
|
431
|
+
this.listenToOnce(
|
|
432
|
+
this.core.activeContainer,
|
|
433
|
+
Events.CONTAINER_LOADEDMETADATA,
|
|
434
|
+
this.onLoadedMetadata,
|
|
435
|
+
)
|
|
438
436
|
}
|
|
439
437
|
|
|
440
438
|
/**
|
|
@@ -475,14 +473,14 @@ export class MediaControl extends UICorePlugin {
|
|
|
475
473
|
this.updateVolumeUI()
|
|
476
474
|
}
|
|
477
475
|
|
|
478
|
-
private
|
|
476
|
+
private onLoadedMetadata() {
|
|
479
477
|
const video = this.core.activePlayback?.el
|
|
480
478
|
|
|
481
479
|
// video.webkitSupportsFullscreen is deprecated but iOS appears to only use this
|
|
482
480
|
// see https://github.com/clappr/clappr/issues/1127
|
|
483
481
|
if (!Fullscreen.fullscreenEnabled() && video.webkitSupportsFullscreen) {
|
|
484
482
|
this.fullScreenOnVideoTagSupported = true
|
|
485
|
-
this.
|
|
483
|
+
this.updateSettings()
|
|
486
484
|
}
|
|
487
485
|
}
|
|
488
486
|
|
|
@@ -754,7 +752,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
754
752
|
this.setInitialVolume()
|
|
755
753
|
this.changeTogglePlay()
|
|
756
754
|
this.bindContainerEvents()
|
|
757
|
-
this.
|
|
755
|
+
this.updateSettings()
|
|
758
756
|
this.core.activeContainer.trigger(
|
|
759
757
|
Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
760
758
|
this.core.activeContainer.isDvrInUse(),
|
|
@@ -989,7 +987,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
989
987
|
}
|
|
990
988
|
}
|
|
991
989
|
|
|
992
|
-
private
|
|
990
|
+
private updateSettings() {
|
|
993
991
|
const newSettings = $.extend(
|
|
994
992
|
true,
|
|
995
993
|
{
|
|
@@ -997,7 +995,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
997
995
|
default: [],
|
|
998
996
|
right: [],
|
|
999
997
|
},
|
|
1000
|
-
this.core.activeContainer
|
|
998
|
+
this.core.activeContainer.settings,
|
|
1001
999
|
)
|
|
1002
1000
|
|
|
1003
1001
|
newSettings.left = orderByOrderPattern(
|
|
@@ -1005,11 +1003,12 @@ export class MediaControl extends UICorePlugin {
|
|
|
1005
1003
|
LEFT_ORDER,
|
|
1006
1004
|
)
|
|
1007
1005
|
|
|
1006
|
+
// actual order of the items appear rendered is controlled by CSS
|
|
1008
1007
|
newSettings.right = [
|
|
1009
1008
|
'fullscreen',
|
|
1010
1009
|
'pip',
|
|
1011
|
-
'
|
|
1012
|
-
'
|
|
1010
|
+
'gear',
|
|
1011
|
+
'cc',
|
|
1013
1012
|
'multicamera',
|
|
1014
1013
|
'playbackrate',
|
|
1015
1014
|
'vr',
|
|
@@ -1021,7 +1020,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
1021
1020
|
!Fullscreen.fullscreenEnabled()) ||
|
|
1022
1021
|
this.options.fullscreenDisable
|
|
1023
1022
|
) {
|
|
1024
|
-
// remove fullscreen from settings if it is
|
|
1023
|
+
// remove fullscreen from settings if it is not available
|
|
1025
1024
|
removeArrayItem(newSettings.default, 'fullscreen')
|
|
1026
1025
|
removeArrayItem(newSettings.left, 'fullscreen')
|
|
1027
1026
|
removeArrayItem(newSettings.right, 'fullscreen')
|
|
@@ -1078,7 +1077,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
1078
1077
|
this.$multiCameraSelector = this.$el.find(
|
|
1079
1078
|
'.media-control-multicamera[data-multicamera]',
|
|
1080
1079
|
)
|
|
1081
|
-
this.$clipText = this.$el.find('.media-clip-text[data-clipstext]')
|
|
1080
|
+
this.$clipText = this.$el.find('.media-clip-text[data-clipstext]') // TODO
|
|
1082
1081
|
this.$clipTextContainer = this.$el.find(
|
|
1083
1082
|
'.media-clip-container[data-clipstext]',
|
|
1084
1083
|
)
|
|
@@ -1108,37 +1107,32 @@ export class MediaControl extends UICorePlugin {
|
|
|
1108
1107
|
*/
|
|
1109
1108
|
getElement(name: MediaControlElement): ZeptoResult | null {
|
|
1110
1109
|
switch (name) {
|
|
1111
|
-
case '
|
|
1110
|
+
case 'audiotracks':
|
|
1112
1111
|
return null
|
|
1113
1112
|
case 'clipText':
|
|
1114
1113
|
return this.$clipText
|
|
1115
|
-
case 'gear':
|
|
1116
|
-
return null
|
|
1117
|
-
case 'pip':
|
|
1118
|
-
return null
|
|
1119
1114
|
case 'playbackRate':
|
|
1120
1115
|
return this.$playbackRate
|
|
1121
1116
|
case 'seekBarContainer':
|
|
1122
1117
|
return this.$seekBarContainer
|
|
1123
|
-
case 'subtitlesSelector':
|
|
1124
|
-
return null
|
|
1125
1118
|
}
|
|
1126
1119
|
}
|
|
1127
1120
|
|
|
1128
|
-
putElement(name: MediaControlElement, element:
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1121
|
+
putElement(name: MediaControlElement, element: HTMLElement) {
|
|
1122
|
+
const panel = this.getElementLocation(name);
|
|
1123
|
+
trace(`${T} putElement`, { name, panel: !!panel })
|
|
1124
|
+
if (panel) {
|
|
1125
|
+
const current = panel.find(`[data-${name}]`)
|
|
1126
|
+
element.setAttribute(`data-${name}`, "")
|
|
1127
|
+
// TODO test
|
|
1128
|
+
if (current.length) {
|
|
1129
|
+
if (current[0] === element) {
|
|
1130
|
+
return
|
|
1131
|
+
}
|
|
1132
|
+
current.replaceWith(element)
|
|
1133
|
+
} else {
|
|
1134
|
+
panel.append(element)
|
|
1135
|
+
}
|
|
1142
1136
|
}
|
|
1143
1137
|
}
|
|
1144
1138
|
|
|
@@ -1424,13 +1418,13 @@ export class MediaControl extends UICorePlugin {
|
|
|
1424
1418
|
|
|
1425
1419
|
// TODO manage by the ads plugin
|
|
1426
1420
|
private onStartAd() {
|
|
1427
|
-
this.advertisementPlaying = true
|
|
1421
|
+
// this.advertisementPlaying = true
|
|
1428
1422
|
this.disable()
|
|
1429
1423
|
}
|
|
1430
1424
|
|
|
1431
1425
|
// TODO manage by the ads plugin
|
|
1432
1426
|
private onFinishAd() {
|
|
1433
|
-
this.advertisementPlaying = false
|
|
1427
|
+
// this.advertisementPlaying = false
|
|
1434
1428
|
this.enable()
|
|
1435
1429
|
}
|
|
1436
1430
|
|
|
@@ -1487,6 +1481,19 @@ export class MediaControl extends UICorePlugin {
|
|
|
1487
1481
|
|
|
1488
1482
|
return isFinite(this.core.activePlayback.getDuration())
|
|
1489
1483
|
}
|
|
1484
|
+
|
|
1485
|
+
private getElementLocation(name: MediaControlElement) {
|
|
1486
|
+
if (this.settings.right?.includes(name)) {
|
|
1487
|
+
return this.getRightPanel();
|
|
1488
|
+
}
|
|
1489
|
+
if (this.settings.left?.includes(name)) {
|
|
1490
|
+
return this.getLeftPanel();
|
|
1491
|
+
}
|
|
1492
|
+
if (this.settings.default?.includes(name)) {
|
|
1493
|
+
return this.getCenterPanel();
|
|
1494
|
+
}
|
|
1495
|
+
return null;
|
|
1496
|
+
}
|
|
1490
1497
|
}
|
|
1491
1498
|
|
|
1492
1499
|
MediaControl.extend = function (properties) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { MediaControl, MediaControlElement } from '../MediaControl'
|
|
3
|
+
import { createMockCore } from '../../../testUtils'
|
|
4
|
+
import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
|
|
5
|
+
|
|
6
|
+
Logger.enable('*')
|
|
7
|
+
setTracer(new LogTracer('MediaControl.test'))
|
|
8
|
+
|
|
9
|
+
describe('MediaControl', () => {
|
|
10
|
+
let core: any
|
|
11
|
+
let mediaControl: MediaControl
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
core = createMockCore()
|
|
15
|
+
})
|
|
16
|
+
describe('putElement', () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
mediaControl = new MediaControl(core)
|
|
19
|
+
core.emit('core:ready')
|
|
20
|
+
core.activeContainer.settings = {}
|
|
21
|
+
core.emit('core:active:container:changed', core.activeContainer)
|
|
22
|
+
})
|
|
23
|
+
describe.each([
|
|
24
|
+
['pip' as MediaControlElement],
|
|
25
|
+
['gear' as MediaControlElement],
|
|
26
|
+
['cc' as MediaControlElement],
|
|
27
|
+
// ['multicamera' as MediaControlElement],
|
|
28
|
+
// ['playbackrate' as MediaControlElement],
|
|
29
|
+
// ['vr' as MediaControlElement],
|
|
30
|
+
// ['audiotracks' as MediaControlElement],
|
|
31
|
+
])('%s', (mcName) => {
|
|
32
|
+
it('should put the element in the right panel', () => {
|
|
33
|
+
const element = document.createElement('div')
|
|
34
|
+
element.className = 'my-media-control'
|
|
35
|
+
element.textContent = 'test'
|
|
36
|
+
mediaControl.putElement(mcName, element)
|
|
37
|
+
|
|
38
|
+
expect(mediaControl.el.innerHTML).toMatchSnapshot()
|
|
39
|
+
expect(mediaControl.$el.find('.media-control-right-panel .my-media-control').length).toEqual(1)
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
})
|