@gcorevideo/player 2.22.22 → 2.22.24
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/clappr-nerd-stats/clappr-nerd-stats.scss +0 -3
- package/assets/subtitles/combobox.ejs +1 -1
- package/assets/subtitles/style.scss +0 -1
- package/dist/core.js +1 -1
- package/dist/index.css +1504 -1505
- package/dist/index.js +4367 -4332
- package/dist/plugins/index.css +641 -642
- package/dist/plugins/index.js +5408 -5376
- package/lib/index.plugins.d.ts +2 -2
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +2 -2
- package/lib/plugins/audio-selector/AudioTracks.d.ts +67 -0
- package/lib/plugins/audio-selector/AudioTracks.d.ts.map +1 -0
- package/lib/plugins/audio-selector/AudioTracks.js +181 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -1
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +13 -3
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts +1 -1
- package/lib/plugins/clappr-nerd-stats/NerdStats.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/NerdStats.js +11 -5
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +0 -1
- package/lib/plugins/clappr-nerd-stats/utils.d.ts.map +1 -1
- package/lib/plugins/clappr-nerd-stats/utils.js +0 -3
- package/lib/plugins/media-control/MediaControl.d.ts +2 -1
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +1 -0
- package/lib/plugins/skip-time/SkipTime.d.ts +2 -2
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
- package/lib/plugins/skip-time/SkipTime.js +6 -5
- package/lib/plugins/subtitles/ClosedCaptions.d.ts +3 -3
- package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
- package/lib/plugins/subtitles/ClosedCaptions.js +34 -19
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +1 -0
- package/package.json +1 -1
- package/src/index.plugins.ts +2 -2
- package/src/plugins/audio-selector/{AudioSelector.ts → AudioTracks.ts} +16 -8
- package/src/plugins/audio-selector/__tests__/{AudioSelector.test.ts → AudioTracks.test.ts} +42 -25
- package/src/plugins/audio-selector/__tests__/__snapshots__/AudioSelector.test.ts.snap +66 -0
- package/src/plugins/audio-selector/__tests__/__snapshots__/AudioTracks.test.ts.snap +67 -0
- package/src/plugins/bottom-gear/BottomGear.ts +17 -3
- package/src/plugins/bottom-gear/__tests__/BottomGear.test.ts +22 -1
- package/src/plugins/clappr-nerd-stats/NerdStats.ts +12 -6
- package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +0 -1
- package/src/plugins/clappr-nerd-stats/utils.ts +0 -3
- package/src/plugins/media-control/MediaControl.ts +1 -0
- package/src/plugins/skip-time/SkipTime.ts +45 -38
- package/src/plugins/subtitles/ClosedCaptions.ts +40 -23
- package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +51 -13
- package/src/plugins/subtitles/__tests__/__snapshots__/ClosedCaptions.test.ts.snap +4 -4
- package/src/testUtils.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/assets/subtitles/combobox copy.ejs +0 -16
- /package/assets/{audio-selector → audio-tracks}/style.scss +0 -0
- /package/assets/{audio-selector/track-selector.ejs → audio-tracks/template.ejs} +0 -0
|
@@ -71,7 +71,7 @@ const T = 'plugins.nerd_stats'
|
|
|
71
71
|
* - {@link BottomGear} - where the button is attached
|
|
72
72
|
*
|
|
73
73
|
* - {@link ClapprStats} - to get the metrics from
|
|
74
|
-
*
|
|
74
|
+
*
|
|
75
75
|
* The plugin is rendered as an item in the gear menu.
|
|
76
76
|
*
|
|
77
77
|
* When clicked, it shows an overlay window with the information about the network speed, latency, etc,
|
|
@@ -312,7 +312,7 @@ export class NerdStats extends UICorePlugin {
|
|
|
312
312
|
|
|
313
313
|
private updateMetrics(metrics: PerfMetrics) {
|
|
314
314
|
trace(`${T} updateMetrics`, { custom: this.speedtestMetrics })
|
|
315
|
-
Object.assign(this.metrics, metrics)
|
|
315
|
+
Object.assign(this.metrics, metrics)
|
|
316
316
|
this.metrics.custom = {
|
|
317
317
|
...this.speedtestMetrics,
|
|
318
318
|
}
|
|
@@ -394,9 +394,15 @@ export class NerdStats extends UICorePlugin {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
private updateCustomMetrics() {
|
|
397
|
-
this.$el
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
this.$el
|
|
398
|
+
.find('#nerd-stats-dl-text')
|
|
399
|
+
.text(this.metrics.custom.connectionSpeed.toFixed(2))
|
|
400
|
+
this.$el
|
|
401
|
+
.find('#nerd-stats-ping-text')
|
|
402
|
+
.text(this.metrics.custom.ping.toFixed(2))
|
|
403
|
+
this.$el
|
|
404
|
+
.find('#nerd-stats-jitter-text')
|
|
405
|
+
.text(this.metrics.custom.jitter.toFixed(2))
|
|
400
406
|
}
|
|
401
407
|
|
|
402
408
|
private updateEstimatedQuality() {
|
|
@@ -465,7 +471,7 @@ export class NerdStats extends UICorePlugin {
|
|
|
465
471
|
this.speedtestMetrics.connectionSpeed = 0
|
|
466
472
|
this.speedtestMetrics.ping = 0
|
|
467
473
|
this.speedtestMetrics.jitter = 0
|
|
468
|
-
|
|
474
|
+
|
|
469
475
|
if (clapprStats) {
|
|
470
476
|
clapprStats.clearMetrics()
|
|
471
477
|
this.updateMetrics(clapprStats.exportMetrics())
|
|
@@ -71,9 +71,6 @@ export const drawSummary = (
|
|
|
71
71
|
) => {
|
|
72
72
|
const { connectionSpeed, ping } = customMetrics
|
|
73
73
|
|
|
74
|
-
// if (!connectionSpeed || !ping) {
|
|
75
|
-
// return
|
|
76
|
-
// }
|
|
77
74
|
const downloadQuality = getDownloadQuality(connectionSpeed)
|
|
78
75
|
const pingQuality = getPingQuality(ping)
|
|
79
76
|
const liveQuality = Math.min(downloadQuality, pingQuality)
|
|
@@ -138,6 +138,7 @@ const LEFT_ORDER = [
|
|
|
138
138
|
|
|
139
139
|
export enum ExtendedEvents {
|
|
140
140
|
MEDIACONTROL_VOLUME = 'mediacontrol:volume',
|
|
141
|
+
MEDIACONTROL_MENU_COLLAPSE = 'mediacontrol:menu:collapse',
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
const { Config, Fullscreen, formatTime, extend, removeArrayItem } = Utils
|
|
@@ -1,113 +1,120 @@
|
|
|
1
|
-
import { UICorePlugin
|
|
1
|
+
import { UICorePlugin, Browser, Playback, Events, template } from '@clappr/core'
|
|
2
2
|
|
|
3
|
-
import { CLAPPR_VERSION } from '../../build.js'
|
|
3
|
+
import { CLAPPR_VERSION } from '../../build.js'
|
|
4
4
|
|
|
5
|
-
import pluginHtml from '../../../assets/skip-time/skip-time.ejs'
|
|
6
|
-
import '../../../assets/skip-time/style.scss'
|
|
5
|
+
import pluginHtml from '../../../assets/skip-time/skip-time.ejs'
|
|
6
|
+
import '../../../assets/skip-time/style.scss'
|
|
7
7
|
|
|
8
|
-
type Position = 'mid' | 'left' | 'right'
|
|
8
|
+
type Position = 'mid' | 'left' | 'right'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* `PLUGIN` that adds skip controls to the media control UI.
|
|
12
12
|
* @beta
|
|
13
13
|
*/
|
|
14
|
-
export class SkipTime extends
|
|
14
|
+
export class SkipTime extends UICorePlugin {
|
|
15
15
|
get name() {
|
|
16
|
-
return 'skip_time'
|
|
16
|
+
return 'skip_time'
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
get supportedVersion() {
|
|
20
|
-
return { min: CLAPPR_VERSION }
|
|
20
|
+
return { min: CLAPPR_VERSION }
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
get container() {
|
|
24
|
-
return this.core && this.core.activeContainer
|
|
24
|
+
return this.core && this.core.activeContainer
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
get template() {
|
|
28
|
-
return template(pluginHtml)
|
|
28
|
+
return template(pluginHtml)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
override get attributes() {
|
|
32
32
|
return {
|
|
33
|
-
|
|
34
|
-
'data-skip-time': ''
|
|
35
|
-
}
|
|
33
|
+
class: this.name + '_plugin',
|
|
34
|
+
'data-skip-time': '',
|
|
35
|
+
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
private position: Position = 'mid'
|
|
38
|
+
private position: Position = 'mid'
|
|
39
39
|
|
|
40
40
|
override get events() {
|
|
41
41
|
return {
|
|
42
42
|
'click [data-skip-left]': 'setBack',
|
|
43
43
|
'click [data-skip-mid]': 'setMidClick',
|
|
44
44
|
'click [data-skip-right]': 'setForward',
|
|
45
|
-
}
|
|
45
|
+
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
override bindEvents() {
|
|
49
|
-
this.listenTo(this.core, Events.CORE_READY, this.render)
|
|
49
|
+
this.listenTo(this.core, Events.CORE_READY, this.render)
|
|
50
50
|
if (!this.container) {
|
|
51
|
-
return
|
|
51
|
+
return
|
|
52
52
|
}
|
|
53
|
-
this.listenTo(
|
|
53
|
+
this.listenTo(
|
|
54
|
+
this.container,
|
|
55
|
+
Events.CONTAINER_DBLCLICK,
|
|
56
|
+
this.handleRewindClicks,
|
|
57
|
+
)
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
setBack() {
|
|
57
|
-
this.position = 'left'
|
|
61
|
+
this.position = 'left'
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
handleRewindClicks() {
|
|
61
|
-
if (
|
|
62
|
-
this.
|
|
65
|
+
if (
|
|
66
|
+
this.core.getPlaybackType() === Playback.LIVE &&
|
|
67
|
+
!this.container.isDvrEnabled()
|
|
68
|
+
) {
|
|
69
|
+
this.toggleFullscreen()
|
|
63
70
|
|
|
64
|
-
return
|
|
71
|
+
return
|
|
65
72
|
}
|
|
66
73
|
if (Browser.isMobile) {
|
|
67
74
|
if (this.position === 'left') {
|
|
68
|
-
const seekPos = this.container.getCurrentTime() - 10
|
|
75
|
+
const seekPos = this.container.getCurrentTime() - 10
|
|
69
76
|
|
|
70
77
|
if (seekPos < 0) {
|
|
71
|
-
return
|
|
78
|
+
return
|
|
72
79
|
}
|
|
73
|
-
this.container.seek(seekPos)
|
|
80
|
+
this.container.seek(seekPos)
|
|
74
81
|
} else if (this.position === 'right') {
|
|
75
|
-
const seekPos = this.container.getCurrentTime() + 30
|
|
82
|
+
const seekPos = this.container.getCurrentTime() + 30
|
|
76
83
|
|
|
77
84
|
if (seekPos > this.container.getDuration()) {
|
|
78
|
-
return
|
|
85
|
+
return
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
this.container.seek(seekPos)
|
|
88
|
+
this.container.seek(seekPos)
|
|
82
89
|
} else {
|
|
83
|
-
this.toggleFullscreen()
|
|
90
|
+
this.toggleFullscreen()
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
setMidClick() {
|
|
89
|
-
this.position = 'mid'
|
|
96
|
+
this.position = 'mid'
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
setForward() {
|
|
93
|
-
this.position = 'right'
|
|
100
|
+
this.position = 'right'
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
toggleFullscreen() {
|
|
97
|
-
this.trigger(Events.MEDIACONTROL_FULLSCREEN, this.name)
|
|
98
|
-
this.container.fullscreen()
|
|
99
|
-
this.core.toggleFullscreen()
|
|
104
|
+
this.trigger(Events.MEDIACONTROL_FULLSCREEN, this.name)
|
|
105
|
+
this.container.fullscreen()
|
|
106
|
+
this.core.toggleFullscreen()
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
override render() {
|
|
103
|
-
this.$el.html(template(pluginHtml))
|
|
110
|
+
this.$el.html(template(pluginHtml))
|
|
104
111
|
|
|
105
112
|
if (this.core.activeContainer) {
|
|
106
|
-
this.core.activeContainer.$el.append(this.el)
|
|
113
|
+
this.core.activeContainer.$el.append(this.el)
|
|
107
114
|
}
|
|
108
115
|
|
|
109
|
-
this.bindEvents()
|
|
116
|
+
this.bindEvents()
|
|
110
117
|
|
|
111
|
-
return this
|
|
118
|
+
return this
|
|
112
119
|
}
|
|
113
120
|
}
|
|
@@ -13,6 +13,7 @@ import stringHTML from '../../../assets/subtitles/string.ejs'
|
|
|
13
13
|
|
|
14
14
|
import { isFullscreen } from '../utils/fullscreen.js'
|
|
15
15
|
import type { ZeptoResult } from '../../types.js'
|
|
16
|
+
import { ExtendedEvents } from '../media-control/MediaControl.js'
|
|
16
17
|
|
|
17
18
|
const VERSION: string = '2.19.14'
|
|
18
19
|
|
|
@@ -61,7 +62,7 @@ export type ClosedCaptionsPluginSettings = {
|
|
|
61
62
|
export class ClosedCaptions extends UICorePlugin {
|
|
62
63
|
private isPreselectedApplied = false
|
|
63
64
|
|
|
64
|
-
private
|
|
65
|
+
private active = false
|
|
65
66
|
|
|
66
67
|
private track: TextTrackItem | null = null
|
|
67
68
|
|
|
@@ -108,13 +109,17 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
108
109
|
*/
|
|
109
110
|
override get events() {
|
|
110
111
|
return {
|
|
111
|
-
'click
|
|
112
|
-
'click
|
|
112
|
+
'click #cc-select li a': 'onItemSelect',
|
|
113
|
+
'click #cc-button': 'toggleMenu',
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
private get preselectedLanguage(): string {
|
|
117
|
-
return
|
|
118
|
+
return (
|
|
119
|
+
this.core.options.cc?.language ??
|
|
120
|
+
this.core.options.subtitles?.language ??
|
|
121
|
+
''
|
|
122
|
+
)
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
/**
|
|
@@ -134,11 +139,18 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
134
139
|
trace(`${T} onCoreReady`)
|
|
135
140
|
const mediaControl = this.core.getPlugin('media_control')
|
|
136
141
|
assert(mediaControl, 'media_control plugin is required')
|
|
137
|
-
this.listenTo(mediaControl, Events.MEDIACONTROL_RENDERED, this.render)
|
|
142
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_RENDERED, this.render) // TODO mount to media control
|
|
143
|
+
this.listenTo(mediaControl, Events.MEDIACONTROL_HIDE, () => {
|
|
144
|
+
this.hideMenu()
|
|
145
|
+
})
|
|
138
146
|
this.listenTo(
|
|
139
147
|
mediaControl,
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE,
|
|
149
|
+
(from: string) => {
|
|
150
|
+
if (from !== this.name) {
|
|
151
|
+
this.hideMenu()
|
|
152
|
+
}
|
|
153
|
+
},
|
|
142
154
|
)
|
|
143
155
|
}
|
|
144
156
|
|
|
@@ -229,7 +241,7 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
229
241
|
}
|
|
230
242
|
|
|
231
243
|
private onStartAd() {
|
|
232
|
-
if (this.
|
|
244
|
+
if (this.active && this.core.activeContainer) {
|
|
233
245
|
this.hide()
|
|
234
246
|
this.listenTo(
|
|
235
247
|
this.core.activeContainer,
|
|
@@ -256,7 +268,7 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
256
268
|
this.track &&
|
|
257
269
|
this.track.track.mode &&
|
|
258
270
|
Browser.isiOS &&
|
|
259
|
-
this.
|
|
271
|
+
this.active
|
|
260
272
|
|
|
261
273
|
if (shouldShow) {
|
|
262
274
|
this.show()
|
|
@@ -273,7 +285,7 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
273
285
|
* Hides the subtitles menu and the subtitles.
|
|
274
286
|
*/
|
|
275
287
|
hide() {
|
|
276
|
-
this.
|
|
288
|
+
this.active = false
|
|
277
289
|
this.renderIcon()
|
|
278
290
|
this.$line.hide()
|
|
279
291
|
if (this.tracks) {
|
|
@@ -287,7 +299,7 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
287
299
|
* Shows the subtitles menu and the subtitles.
|
|
288
300
|
*/
|
|
289
301
|
show() {
|
|
290
|
-
this.
|
|
302
|
+
this.active = true
|
|
291
303
|
this.renderIcon()
|
|
292
304
|
if (
|
|
293
305
|
this.core.activeContainer &&
|
|
@@ -331,7 +343,8 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
331
343
|
|
|
332
344
|
const mediaControl = this.core.getPlugin('media_control')
|
|
333
345
|
|
|
334
|
-
this.$el.html(ClosedCaptions.template({ tracks: this.tracks }))
|
|
346
|
+
this.$el.html(ClosedCaptions.template({ tracks: this.tracks, i18n: this.core.i18n }))
|
|
347
|
+
this.$el.find('#cc-select').hide()
|
|
335
348
|
this.core.activeContainer.$el.find('#cc-line').remove()
|
|
336
349
|
this.$line = $(ClosedCaptions.templateString())
|
|
337
350
|
this.resizeFont()
|
|
@@ -354,7 +367,6 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
354
367
|
this.clearSubtitleText()
|
|
355
368
|
this.track = item
|
|
356
369
|
|
|
357
|
-
this.hideMenu()
|
|
358
370
|
this.updateSelection()
|
|
359
371
|
}
|
|
360
372
|
|
|
@@ -365,7 +377,7 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
365
377
|
|
|
366
378
|
localStorage.setItem(LOCAL_STORAGE_CC_ID, id)
|
|
367
379
|
this.selectItem(this.findById(Number(id)))
|
|
368
|
-
|
|
380
|
+
this.hideMenu()
|
|
369
381
|
return false
|
|
370
382
|
}
|
|
371
383
|
|
|
@@ -386,22 +398,25 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
386
398
|
}
|
|
387
399
|
|
|
388
400
|
private hideMenu() {
|
|
389
|
-
|
|
401
|
+
trace(`${T} hideMenu`)
|
|
402
|
+
this.$el.find('#cc-select').hide()
|
|
390
403
|
}
|
|
391
404
|
|
|
392
405
|
private toggleMenu() {
|
|
393
|
-
trace(`${T} toggleMenu
|
|
394
|
-
|
|
406
|
+
trace(`${T} toggleMenu`, {display: this.$el.find('#cc-select').css('display')})
|
|
407
|
+
this.core
|
|
408
|
+
.getPlugin('media_control')
|
|
409
|
+
.trigger(ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE, this.name)
|
|
410
|
+
this.$el.find('#cc-select').toggle()
|
|
411
|
+
// TODO hold state, add aria-expanded to the button, add active state to the button
|
|
395
412
|
}
|
|
396
413
|
|
|
397
414
|
private itemElement(id: number): ZeptoResult {
|
|
398
|
-
return (
|
|
399
|
-
this.$(`ul li a[data-cc-select="${id}"]`) as ZeptoResult
|
|
400
|
-
).parent()
|
|
415
|
+
return this.$el.find(`#cc-select li a[data-cc-select="${id}"]`).parent()
|
|
401
416
|
}
|
|
402
417
|
|
|
403
418
|
private allItemElements(): ZeptoResult {
|
|
404
|
-
return this.$('
|
|
419
|
+
return this.$('#cc-select li')
|
|
405
420
|
}
|
|
406
421
|
|
|
407
422
|
private selectSubtitles() {
|
|
@@ -453,7 +468,9 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
453
468
|
trace(`${T} highlightCurrentSubtitles`, {
|
|
454
469
|
track: this.track?.id,
|
|
455
470
|
})
|
|
456
|
-
const currentLevelElement = this.itemElement(
|
|
471
|
+
const currentLevelElement = this.itemElement(
|
|
472
|
+
this.track ? this.track.id : -1,
|
|
473
|
+
)
|
|
457
474
|
currentLevelElement
|
|
458
475
|
.addClass('current')
|
|
459
476
|
.find('a')
|
|
@@ -461,7 +478,7 @@ export class ClosedCaptions extends UICorePlugin {
|
|
|
461
478
|
}
|
|
462
479
|
|
|
463
480
|
private renderIcon() {
|
|
464
|
-
const icon = this.
|
|
481
|
+
const icon = this.active ? subtitlesOnIcon : subtitlesOffIcon
|
|
465
482
|
|
|
466
483
|
this.$el.find('span.cc-text').html(icon)
|
|
467
484
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
2
|
|
|
3
3
|
import { ClosedCaptions } from '../ClosedCaptions.js'
|
|
4
|
-
import { createMockCore, createMockMediaControl } from '../../../testUtils.js'
|
|
4
|
+
import { createMockCore, createMockMediaControl } from '../../../testUtils.js'
|
|
5
|
+
import { ExtendedEvents } from '../../media-control/MediaControl.js'
|
|
6
|
+
|
|
7
|
+
import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
|
|
8
|
+
// import { Events } from '@clappr/core';
|
|
9
|
+
|
|
10
|
+
// Logger.enable('*')
|
|
11
|
+
// setTracer(new LogTracer('ClosedCaptions.test'))
|
|
5
12
|
|
|
6
13
|
describe('ClosedCaptions', () => {
|
|
7
|
-
let core: any
|
|
8
|
-
let mediaControl: any
|
|
9
|
-
let cc: ClosedCaptions
|
|
14
|
+
let core: any
|
|
15
|
+
let mediaControl: any
|
|
16
|
+
let cc: ClosedCaptions
|
|
10
17
|
beforeEach(() => {
|
|
11
18
|
core = createMockCore()
|
|
12
19
|
mediaControl = createMockMediaControl(core)
|
|
@@ -20,9 +27,9 @@ describe('ClosedCaptions', () => {
|
|
|
20
27
|
})
|
|
21
28
|
describe('basically', () => {
|
|
22
29
|
beforeEach(() => {
|
|
23
|
-
core.emit(
|
|
30
|
+
core.emit(Events.CORE_READY)
|
|
24
31
|
core.activePlayback.el = document.createElement('video')
|
|
25
|
-
core.emit(
|
|
32
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED, core.activeContainer)
|
|
26
33
|
core.activePlayback.closedCaptionsTracks = [
|
|
27
34
|
{
|
|
28
35
|
id: 1,
|
|
@@ -33,7 +40,7 @@ describe('ClosedCaptions', () => {
|
|
|
33
40
|
label: 'English',
|
|
34
41
|
mode: 'hidden',
|
|
35
42
|
cues: [],
|
|
36
|
-
}
|
|
43
|
+
},
|
|
37
44
|
},
|
|
38
45
|
{
|
|
39
46
|
id: 2,
|
|
@@ -44,16 +51,47 @@ describe('ClosedCaptions', () => {
|
|
|
44
51
|
label: 'Spanish',
|
|
45
52
|
mode: 'hidden',
|
|
46
53
|
cues: [],
|
|
47
|
-
}
|
|
48
|
-
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
49
56
|
]
|
|
50
|
-
core.activePlayback.emit(
|
|
51
|
-
core.activeContainer.emit(
|
|
57
|
+
core.activePlayback.emit(Events.PLAYBACK_SUBTITLE_AVAILABLE)
|
|
58
|
+
core.activeContainer.emit(Events.CONTAINER_SUBTITLE_AVAILABLE)
|
|
52
59
|
})
|
|
53
60
|
it('should render', () => {
|
|
54
61
|
expect(cc.el.innerHTML).toMatchSnapshot()
|
|
55
|
-
expect(cc.$el.find('
|
|
62
|
+
expect(cc.$el.find('#cc-button').length).toEqual(1)
|
|
56
63
|
expect(mediaControl.mount).toHaveBeenCalledWith('cc', cc.$el)
|
|
57
64
|
})
|
|
65
|
+
describe('when button is clicked', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
cc.$el.find('#cc-button').click()
|
|
68
|
+
})
|
|
69
|
+
it('should open menu', () => {
|
|
70
|
+
expect(cc.$el.find('#cc-select').css('display')).not.toBe('none')
|
|
71
|
+
})
|
|
72
|
+
it('should collapse all other menus', () => {
|
|
73
|
+
expect(mediaControl.trigger).toHaveBeenCalledWith(
|
|
74
|
+
ExtendedEvents.MEDIACONTROL_MENU_COLLAPSE,
|
|
75
|
+
'cc',
|
|
76
|
+
)
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
describe('when clicked twice', () => {
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
cc.$el.find('#cc-button').click().click()
|
|
82
|
+
})
|
|
83
|
+
it('should collapse the menu', () => {
|
|
84
|
+
expect(cc.$el.find('#cc-select').css('display')).toBe('none')
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
describe('when media control is hidden', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
cc.$el.find('#cc-button').click()
|
|
90
|
+
mediaControl.trigger(Events.MEDIACONTROL_HIDE)
|
|
91
|
+
})
|
|
92
|
+
it('should hide menu', () => {
|
|
93
|
+
expect(cc.$el.find('#cc-select').css('display')).toBe('none')
|
|
94
|
+
})
|
|
95
|
+
})
|
|
58
96
|
})
|
|
59
|
-
})
|
|
97
|
+
})
|
|
@@ -5,21 +5,21 @@ exports[`ClosedCaptions > basically > should render 1`] = `
|
|
|
5
5
|
<span class="cc-text">/assets/icons/new/subtitles-off.svg</span>
|
|
6
6
|
</button>
|
|
7
7
|
|
|
8
|
-
<ul class="gcore-skin-bg-color" id="cc-select">
|
|
8
|
+
<ul class="gcore-skin-bg-color" id="cc-select" style="display: none;">
|
|
9
9
|
|
|
10
|
-
<li>
|
|
10
|
+
<li class="">
|
|
11
11
|
<a href="#" class="gcore-skin-text-color" data-cc-select="1">
|
|
12
12
|
English
|
|
13
13
|
</a>
|
|
14
14
|
</li>
|
|
15
15
|
|
|
16
|
-
<li>
|
|
16
|
+
<li class="">
|
|
17
17
|
<a href="#" class="gcore-skin-text-color" data-cc-select="2">
|
|
18
18
|
Spanish
|
|
19
19
|
</a>
|
|
20
20
|
</li>
|
|
21
21
|
|
|
22
|
-
<li class="current"><a href="#" class="gcore-skin-text-color gcore-skin-active" data-cc-select="-1">
|
|
22
|
+
<li class="current"><a href="#" class="gcore-skin-text-color gcore-skin-active" data-cc-select="-1">off</a></li>
|
|
23
23
|
</ul>
|
|
24
24
|
"
|
|
25
25
|
`;
|