@gcorevideo/player 2.21.4 → 2.21.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/dvr-controls/dvr_controls.scss +7 -25
- package/assets/dvr-controls/index.ejs +2 -2
- package/assets/media-control/media-control.scss +8 -3
- package/assets/media-control/width370.scss +1 -1
- package/assets/style/theme.scss +1 -1
- package/dist/core.js +1 -1
- package/dist/index.css +603 -608
- package/dist/index.js +78 -77
- package/dist/plugins/index.css +1073 -1078
- package/dist/plugins/index.js +77 -74
- package/lib/plugins/dvr-controls/DvrControls.d.ts +0 -3
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DvrControls.js +13 -38
- package/lib/plugins/media-control/MediaControl.d.ts +10 -14
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +63 -37
- package/lib/testUtils.d.ts +4 -1
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +10 -11
- package/package.json +1 -1
- package/src/plugins/dvr-controls/DvrControls.ts +16 -44
- package/src/plugins/dvr-controls/__tests__/DvrControls.test.ts +18 -22
- package/src/plugins/dvr-controls/__tests__/__snapshots__/DvrControls.test.ts.snap +6 -30
- package/src/plugins/media-control/MediaControl.ts +88 -50
- package/src/plugins/media-control/__tests__/MediaControl.test.ts +89 -0
- package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +124 -0
- package/src/testUtils.ts +10 -11
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -43,12 +43,29 @@ import fullscreenOnIcon from '../../../assets/icons/new/fullscreen-on.svg'
|
|
|
43
43
|
*/
|
|
44
44
|
export type MediaControlElement =
|
|
45
45
|
| 'audiotracks'
|
|
46
|
+
| 'cc'
|
|
46
47
|
| 'clipText'
|
|
48
|
+
| 'dvr'
|
|
49
|
+
| 'duration'
|
|
47
50
|
| 'gear'
|
|
48
51
|
| 'pip'
|
|
49
52
|
| 'playbackRate'
|
|
53
|
+
| 'position'
|
|
50
54
|
| 'seekBarContainer'
|
|
51
|
-
|
|
55
|
+
|
|
56
|
+
type MediaControlSettings = {
|
|
57
|
+
left: MediaControlElement[]
|
|
58
|
+
right: MediaControlElement[]
|
|
59
|
+
default: MediaControlElement[]
|
|
60
|
+
seekEnabled: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const DEFAULT_SETTINGS: MediaControlSettings = {
|
|
64
|
+
left: [],
|
|
65
|
+
right: [],
|
|
66
|
+
default: [],
|
|
67
|
+
seekEnabled: true,
|
|
68
|
+
}
|
|
52
69
|
|
|
53
70
|
/**
|
|
54
71
|
* Custom events emitted by the plugins to communicate with one another
|
|
@@ -66,7 +83,8 @@ const T = 'plugins.media_control'
|
|
|
66
83
|
const LEFT_ORDER = [
|
|
67
84
|
'playpause',
|
|
68
85
|
'playstop',
|
|
69
|
-
'live',
|
|
86
|
+
// 'live',
|
|
87
|
+
'dvr',
|
|
70
88
|
'volume',
|
|
71
89
|
'position',
|
|
72
90
|
'duration',
|
|
@@ -118,8 +136,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
118
136
|
|
|
119
137
|
private intendedVolume = 100
|
|
120
138
|
|
|
121
|
-
private isHD = false
|
|
122
|
-
|
|
123
139
|
private keepVisible = false
|
|
124
140
|
|
|
125
141
|
private kibo: Kibo
|
|
@@ -131,7 +147,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
131
147
|
|
|
132
148
|
private rendered = false
|
|
133
149
|
|
|
134
|
-
private settings:
|
|
150
|
+
private settings: MediaControlSettings = DEFAULT_SETTINGS
|
|
135
151
|
|
|
136
152
|
private userDisabled = false
|
|
137
153
|
|
|
@@ -320,8 +336,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
320
336
|
* @internal
|
|
321
337
|
*/
|
|
322
338
|
override bindEvents() {
|
|
323
|
-
// @ts-ignore
|
|
324
|
-
this.stopListening()
|
|
325
339
|
this.listenTo(
|
|
326
340
|
this.core,
|
|
327
341
|
Events.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
@@ -399,12 +413,12 @@ export class MediaControl extends UICorePlugin {
|
|
|
399
413
|
this.listenTo(
|
|
400
414
|
this.core.activeContainer,
|
|
401
415
|
Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
402
|
-
this.
|
|
416
|
+
this.onDvrStateChanged,
|
|
403
417
|
)
|
|
404
418
|
this.listenTo(
|
|
405
419
|
this.core.activeContainer,
|
|
406
420
|
Events.CONTAINER_HIGHDEFINITIONUPDATE,
|
|
407
|
-
this.
|
|
421
|
+
this.onHdUpdate,
|
|
408
422
|
)
|
|
409
423
|
this.listenTo(
|
|
410
424
|
this.core.activeContainer,
|
|
@@ -427,7 +441,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
427
441
|
Events.CONTAINER_OPTIONS_CHANGE,
|
|
428
442
|
this.setInitialVolume,
|
|
429
443
|
)
|
|
430
|
-
|
|
444
|
+
// wait until the metadata has loaded and then check if fullscreen on video tag is supported
|
|
431
445
|
this.listenToOnce(
|
|
432
446
|
this.core.activeContainer,
|
|
433
447
|
Events.CONTAINER_LOADEDMETADATA,
|
|
@@ -480,7 +494,12 @@ export class MediaControl extends UICorePlugin {
|
|
|
480
494
|
// see https://github.com/clappr/clappr/issues/1127
|
|
481
495
|
if (!Fullscreen.fullscreenEnabled() && video.webkitSupportsFullscreen) {
|
|
482
496
|
this.fullScreenOnVideoTagSupported = true
|
|
483
|
-
|
|
497
|
+
}
|
|
498
|
+
this.updateSettings()
|
|
499
|
+
if (this.core.activeContainer.getPlaybackType() === Playback.LIVE) {
|
|
500
|
+
this.$el.addClass('live')
|
|
501
|
+
} else {
|
|
502
|
+
this.$el.removeClass('live')
|
|
484
503
|
}
|
|
485
504
|
}
|
|
486
505
|
|
|
@@ -491,8 +510,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
491
510
|
}
|
|
492
511
|
|
|
493
512
|
assert.ok(this.$volumeBarContainer, 'volume bar container must be present')
|
|
494
|
-
// update volume bar scrubber/fill on bar mode
|
|
495
|
-
// this.$volumeBarContainer.find('.bar-fill-2').css({});
|
|
496
513
|
const containerWidth = this.$volumeBarContainer.width()
|
|
497
514
|
|
|
498
515
|
assert.ok(
|
|
@@ -718,17 +735,18 @@ export class MediaControl extends UICorePlugin {
|
|
|
718
735
|
// if the container is not ready etc
|
|
719
736
|
this.intendedVolume = value
|
|
720
737
|
this.persistConfig && !isInitialVolume && Config.persist('volume', value)
|
|
738
|
+
// TODO
|
|
721
739
|
const setWhenContainerReady = () => {
|
|
722
|
-
if (this.
|
|
723
|
-
this.
|
|
740
|
+
if (this.core.activeContainer && this.core.activeContainer.isReady) {
|
|
741
|
+
this.core.activeContainer.setVolume(value)
|
|
724
742
|
} else {
|
|
725
|
-
this.listenToOnce(this.
|
|
726
|
-
this.
|
|
743
|
+
this.listenToOnce(this.core.activeContainer, Events.CONTAINER_READY, () => {
|
|
744
|
+
this.core.activeContainer.setVolume(value)
|
|
727
745
|
})
|
|
728
746
|
}
|
|
729
747
|
}
|
|
730
748
|
|
|
731
|
-
if (!this.
|
|
749
|
+
if (!this.core.activeContainer) {
|
|
732
750
|
this.listenToOnce(this, Events.MEDIACONTROL_CONTAINERCHANGED, () =>
|
|
733
751
|
setWhenContainerReady(),
|
|
734
752
|
)
|
|
@@ -740,7 +758,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
740
758
|
private toggleFullscreen() {
|
|
741
759
|
if (!Browser.isMobile) {
|
|
742
760
|
this.trigger(Events.MEDIACONTROL_FULLSCREEN, this.name)
|
|
743
|
-
this.
|
|
761
|
+
this.core.activeContainer.fullscreen()
|
|
744
762
|
this.core.toggleFullscreen()
|
|
745
763
|
this.resetUserKeepVisible()
|
|
746
764
|
}
|
|
@@ -753,6 +771,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
753
771
|
this.changeTogglePlay()
|
|
754
772
|
this.bindContainerEvents()
|
|
755
773
|
this.updateSettings()
|
|
774
|
+
// TODO remove
|
|
756
775
|
this.core.activeContainer.trigger(
|
|
757
776
|
Events.CONTAINER_PLAYBACKDVRSTATECHANGED,
|
|
758
777
|
this.core.activeContainer.isDvrInUse(),
|
|
@@ -847,9 +866,9 @@ export class MediaControl extends UICorePlugin {
|
|
|
847
866
|
// default to 100%
|
|
848
867
|
this.currentSeekBarPercentage = 100
|
|
849
868
|
if (
|
|
850
|
-
this.
|
|
851
|
-
(this.
|
|
852
|
-
this.
|
|
869
|
+
this.core.activeContainer &&
|
|
870
|
+
(this.core.activeContainer.getPlaybackType() !== Playback.LIVE ||
|
|
871
|
+
this.core.activeContainer.isDvrInUse())
|
|
853
872
|
) {
|
|
854
873
|
this.currentSeekBarPercentage =
|
|
855
874
|
(this.currentPositionValue / this.currentDurationValue) * 100
|
|
@@ -885,21 +904,13 @@ export class MediaControl extends UICorePlugin {
|
|
|
885
904
|
let pos = (offsetX / this.$seekBarContainer.width()) * 100
|
|
886
905
|
|
|
887
906
|
pos = Math.min(100, Math.max(pos, 0))
|
|
888
|
-
this.
|
|
907
|
+
this.core.activeContainer && this.core.activeContainer.seekPercentage(pos)
|
|
889
908
|
|
|
890
909
|
this.setSeekPercentage(pos)
|
|
891
910
|
|
|
892
911
|
return false
|
|
893
912
|
}
|
|
894
913
|
|
|
895
|
-
private setKeepVisible() {
|
|
896
|
-
this.keepVisible = true
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
private resetKeepVisible() {
|
|
900
|
-
this.keepVisible = false
|
|
901
|
-
}
|
|
902
|
-
|
|
903
914
|
private setUserKeepVisible() {
|
|
904
915
|
this.userKeepVisible = true
|
|
905
916
|
}
|
|
@@ -998,11 +1009,19 @@ export class MediaControl extends UICorePlugin {
|
|
|
998
1009
|
this.core.activeContainer.settings,
|
|
999
1010
|
)
|
|
1000
1011
|
|
|
1012
|
+
// TODO make order controlled via CSS
|
|
1001
1013
|
newSettings.left = orderByOrderPattern(
|
|
1002
1014
|
[...newSettings.left, 'clipsText', 'volume'],
|
|
1003
1015
|
LEFT_ORDER,
|
|
1004
1016
|
)
|
|
1005
1017
|
|
|
1018
|
+
if (
|
|
1019
|
+
this.core.activePlayback.getPlaybackType() === Playback.LIVE &&
|
|
1020
|
+
this.core.activePlayback.dvrEnabled
|
|
1021
|
+
) {
|
|
1022
|
+
newSettings.left.push('dvr')
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1006
1025
|
// actual order of the items appear rendered is controlled by CSS
|
|
1007
1026
|
newSettings.right = [
|
|
1008
1027
|
'fullscreen',
|
|
@@ -1029,12 +1048,13 @@ export class MediaControl extends UICorePlugin {
|
|
|
1029
1048
|
removeArrayItem(newSettings.default, 'hd-indicator')
|
|
1030
1049
|
removeArrayItem(newSettings.left, 'hd-indicator')
|
|
1031
1050
|
|
|
1051
|
+
// TODO get from container's settings
|
|
1032
1052
|
if (this.core.activePlayback.name === 'html5_video') {
|
|
1033
1053
|
newSettings.seekEnabled = this.isSeekEnabledForHtml5Playback()
|
|
1034
1054
|
}
|
|
1035
1055
|
|
|
1036
1056
|
const settingsChanged =
|
|
1037
|
-
|
|
1057
|
+
serializeSettings(this.settings) !== serializeSettings(newSettings)
|
|
1038
1058
|
|
|
1039
1059
|
if (settingsChanged) {
|
|
1040
1060
|
this.settings = newSettings
|
|
@@ -1042,8 +1062,8 @@ export class MediaControl extends UICorePlugin {
|
|
|
1042
1062
|
}
|
|
1043
1063
|
}
|
|
1044
1064
|
|
|
1045
|
-
private
|
|
1046
|
-
|
|
1065
|
+
private onHdUpdate(isHD: boolean) {
|
|
1066
|
+
// TODO render?
|
|
1047
1067
|
}
|
|
1048
1068
|
|
|
1049
1069
|
private createCachedElements() {
|
|
@@ -1119,11 +1139,11 @@ export class MediaControl extends UICorePlugin {
|
|
|
1119
1139
|
}
|
|
1120
1140
|
|
|
1121
1141
|
putElement(name: MediaControlElement, element: HTMLElement) {
|
|
1122
|
-
const panel = this.getElementLocation(name)
|
|
1142
|
+
const panel = this.getElementLocation(name)
|
|
1123
1143
|
trace(`${T} putElement`, { name, panel: !!panel })
|
|
1124
1144
|
if (panel) {
|
|
1125
1145
|
const current = panel.find(`[data-${name}]`)
|
|
1126
|
-
element.setAttribute(`data-${name}`,
|
|
1146
|
+
element.setAttribute(`data-${name}`, '')
|
|
1127
1147
|
// TODO test
|
|
1128
1148
|
if (current.length) {
|
|
1129
1149
|
if (current[0] === element) {
|
|
@@ -1137,22 +1157,23 @@ export class MediaControl extends UICorePlugin {
|
|
|
1137
1157
|
}
|
|
1138
1158
|
|
|
1139
1159
|
/**
|
|
1140
|
-
*
|
|
1141
|
-
* @
|
|
1160
|
+
* Toggle the visibility of a media control element
|
|
1161
|
+
* @param name - The name of the media control element
|
|
1162
|
+
* @param show - Whether to show or hide the element
|
|
1142
1163
|
*/
|
|
1143
|
-
|
|
1164
|
+
toggleElement(name: MediaControlElement, show: boolean) {
|
|
1165
|
+
this.$el.find(`[data-${name}]`).toggle(show)
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
private getRightPanel() {
|
|
1144
1169
|
return this.$el.find('.media-control-right-panel')
|
|
1145
1170
|
}
|
|
1146
1171
|
|
|
1147
|
-
|
|
1148
|
-
* Get the left panel area to append custom elements to
|
|
1149
|
-
* @returns ZeptoSelector of the left panel element
|
|
1150
|
-
*/
|
|
1151
|
-
getLeftPanel() {
|
|
1172
|
+
private getLeftPanel() {
|
|
1152
1173
|
return this.$el.find('.media-control-left-panel')
|
|
1153
1174
|
}
|
|
1154
1175
|
|
|
1155
|
-
getCenterPanel() {
|
|
1176
|
+
private getCenterPanel() {
|
|
1156
1177
|
return this.$el.find('.media-control-center-panel')
|
|
1157
1178
|
}
|
|
1158
1179
|
|
|
@@ -1389,7 +1410,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
1389
1410
|
}, 0)
|
|
1390
1411
|
|
|
1391
1412
|
this.parseColors()
|
|
1392
|
-
this.highDefinitionUpdate(this.isHD)
|
|
1393
1413
|
|
|
1394
1414
|
this.core.$el.append(this.el)
|
|
1395
1415
|
|
|
@@ -1484,18 +1504,36 @@ export class MediaControl extends UICorePlugin {
|
|
|
1484
1504
|
|
|
1485
1505
|
private getElementLocation(name: MediaControlElement) {
|
|
1486
1506
|
if (this.settings.right?.includes(name)) {
|
|
1487
|
-
return this.getRightPanel()
|
|
1507
|
+
return this.getRightPanel()
|
|
1488
1508
|
}
|
|
1489
1509
|
if (this.settings.left?.includes(name)) {
|
|
1490
|
-
return this.getLeftPanel()
|
|
1510
|
+
return this.getLeftPanel()
|
|
1491
1511
|
}
|
|
1492
1512
|
if (this.settings.default?.includes(name)) {
|
|
1493
|
-
return this.getCenterPanel()
|
|
1513
|
+
return this.getCenterPanel()
|
|
1514
|
+
}
|
|
1515
|
+
return null
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
private onDvrStateChanged(dvrInUse: boolean) {
|
|
1519
|
+
if (dvrInUse) {
|
|
1520
|
+
this.$el.addClass('dvr')
|
|
1521
|
+
} else {
|
|
1522
|
+
this.$el.removeClass('dvr')
|
|
1494
1523
|
}
|
|
1495
|
-
return null;
|
|
1496
1524
|
}
|
|
1497
1525
|
}
|
|
1498
1526
|
|
|
1499
1527
|
MediaControl.extend = function (properties) {
|
|
1500
1528
|
return extend(MediaControl, properties)
|
|
1501
1529
|
}
|
|
1530
|
+
|
|
1531
|
+
function serializeSettings(s: MediaControlSettings) {
|
|
1532
|
+
return s.left
|
|
1533
|
+
.slice()
|
|
1534
|
+
.sort()
|
|
1535
|
+
.concat(s.right.slice().sort())
|
|
1536
|
+
.concat(s.default.slice().sort())
|
|
1537
|
+
.concat([s.seekEnabled as any])
|
|
1538
|
+
.join(',')
|
|
1539
|
+
}
|
|
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
|
2
2
|
import { MediaControl, MediaControlElement } from '../MediaControl'
|
|
3
3
|
import { createMockCore } from '../../../testUtils'
|
|
4
4
|
import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
|
|
5
|
+
import { Events, Playback } from '@clappr/core'
|
|
5
6
|
|
|
6
7
|
Logger.enable('*')
|
|
7
8
|
setTracer(new LogTracer('MediaControl.test'))
|
|
@@ -13,6 +14,31 @@ describe('MediaControl', () => {
|
|
|
13
14
|
beforeEach(() => {
|
|
14
15
|
core = createMockCore()
|
|
15
16
|
})
|
|
17
|
+
describe('playback type', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
mediaControl = new MediaControl(core)
|
|
20
|
+
core.emit('core:ready')
|
|
21
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED, core.activeContainer)
|
|
22
|
+
})
|
|
23
|
+
describe('when live', () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
core.activeContainer.getPlaybackType.mockReturnValue(Playback.LIVE)
|
|
26
|
+
core.activeContainer.emit(Events.CONTAINER_LOADEDMETADATA)
|
|
27
|
+
})
|
|
28
|
+
it('should apply live style class', () => {
|
|
29
|
+
expect(mediaControl.$el.hasClass('live')).toBe(true)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
describe('when vod', () => {
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
core.activeContainer.getPlaybackType.mockReturnValue(Playback.VOD)
|
|
35
|
+
core.activeContainer.emit(Events.CONTAINER_LOADEDMETADATA)
|
|
36
|
+
})
|
|
37
|
+
it('should not apply live style class', () => {
|
|
38
|
+
expect(mediaControl.$el.hasClass('live')).toBe(false)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
})
|
|
16
42
|
describe('putElement', () => {
|
|
17
43
|
beforeEach(() => {
|
|
18
44
|
mediaControl = new MediaControl(core)
|
|
@@ -28,6 +54,7 @@ describe('MediaControl', () => {
|
|
|
28
54
|
// ['playbackrate' as MediaControlElement],
|
|
29
55
|
// ['vr' as MediaControlElement],
|
|
30
56
|
// ['audiotracks' as MediaControlElement],
|
|
57
|
+
// dvr controls
|
|
31
58
|
])('%s', (mcName) => {
|
|
32
59
|
it('should put the element in the right panel', () => {
|
|
33
60
|
const element = document.createElement('div')
|
|
@@ -40,4 +67,66 @@ describe('MediaControl', () => {
|
|
|
40
67
|
})
|
|
41
68
|
})
|
|
42
69
|
})
|
|
70
|
+
describe('updateSettings', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
mediaControl = new MediaControl(core)
|
|
73
|
+
core.emit('core:ready')
|
|
74
|
+
})
|
|
75
|
+
describe('dvr', () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
core.activeContainer.settings = {
|
|
78
|
+
left: ['playpause', 'position', 'duration'],
|
|
79
|
+
seekEnabled: true,
|
|
80
|
+
}
|
|
81
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED, core.activeContainer)
|
|
82
|
+
})
|
|
83
|
+
describe('when enabled', () => {
|
|
84
|
+
beforeEach(() => {
|
|
85
|
+
core.activePlayback.dvrEnabled = true
|
|
86
|
+
core.activeContainer.isDvrEnabled.mockReturnValue(true)
|
|
87
|
+
core.activeContainer.emit(Events.CONTAINER_SETTINGSUPDATE, true)
|
|
88
|
+
})
|
|
89
|
+
it('should enable DVR controls', () => {
|
|
90
|
+
const element = document.createElement('div')
|
|
91
|
+
element.className = 'my-dvr-controls'
|
|
92
|
+
element.textContent = 'live'
|
|
93
|
+
mediaControl.putElement('dvr', element)
|
|
94
|
+
expect(mediaControl.el.innerHTML).toMatchSnapshot()
|
|
95
|
+
expect(mediaControl.$el.find('.media-control-left-panel .my-dvr-controls').length).toEqual(1)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
describe('when disabled', () => {
|
|
99
|
+
it('should disable DVR controls', () => {
|
|
100
|
+
const element = document.createElement('div')
|
|
101
|
+
element.className = 'my-dvr-controls'
|
|
102
|
+
element.textContent = 'live'
|
|
103
|
+
mediaControl.putElement('dvr', element)
|
|
104
|
+
expect(mediaControl.el.innerHTML).toMatchSnapshot()
|
|
105
|
+
expect(mediaControl.$el.find('.media-control-left-panel .my-dvr-controls').length).toEqual(0)
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
describe('dvr mode', () => {
|
|
111
|
+
beforeEach(() => {
|
|
112
|
+
mediaControl = new MediaControl(core)
|
|
113
|
+
core.emit(Events.CORE_READY)
|
|
114
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED, core.activeContainer)
|
|
115
|
+
})
|
|
116
|
+
describe('by default', () => {
|
|
117
|
+
it('should not apply DVR style class', () => {
|
|
118
|
+
expect(mediaControl.$el.hasClass('dvr')).toBe(false)
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
describe('when in use', () => {
|
|
122
|
+
beforeEach(() => {
|
|
123
|
+
core.activeContainer.isDvrInUse.mockReturnValue(true)
|
|
124
|
+
core.activePlayback.dvrInUse = true
|
|
125
|
+
core.activeContainer.emit(Events.CONTAINER_PLAYBACKDVRSTATECHANGED, true)
|
|
126
|
+
})
|
|
127
|
+
it('should apply DVR style class', () => {
|
|
128
|
+
expect(mediaControl.$el.hasClass('dvr')).toBe(true)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
43
132
|
})
|
|
@@ -173,3 +173,127 @@ exports[`MediaControl > putElement > pip > should put the element in the right p
|
|
|
173
173
|
</div>
|
|
174
174
|
<style>:root {}</style>"
|
|
175
175
|
`;
|
|
176
|
+
|
|
177
|
+
exports[`MediaControl > updateSettings > dvr > when disabled > should disable DVR controls 1`] = `
|
|
178
|
+
"<div class="media-control-background" data-background=""></div>
|
|
179
|
+
|
|
180
|
+
<div class="media-control-layer gcore-skin-bg-color" data-controls="">
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<div class="media-control-left-panel" data-media-control="">
|
|
195
|
+
|
|
196
|
+
<div class="drawer-container" data-volume="">
|
|
197
|
+
<div class="drawer-icon-container" data-volume="">
|
|
198
|
+
<div class="drawer-icon media-control-icon gcore-skin-button-color" data-volume="">/assets/icons/new/volume-max.svg</div>
|
|
199
|
+
<span class="drawer-text" data-volume=""></span>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<div class="bar-container" data-volume="">
|
|
203
|
+
<div class="bar-background" data-volume="">
|
|
204
|
+
<div class="bar-fill-1 gcore-skin-main-color" data-volume="" style=""></div>
|
|
205
|
+
</div>
|
|
206
|
+
<div class="bar-scrubber" data-volume="" style="">
|
|
207
|
+
<div class="bar-scrubber-icon gcore-skin-main-color" data-volume=""></div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div class="media-control-indicator gcore-skin-text-color" data-position="">00:00</div>
|
|
214
|
+
|
|
215
|
+
<div class="media-control-indicator gcore-skin-text-color" data-duration="">00:00</div>
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
<div class="media-clip-container gcore-skin-text-color" data-clipstext="">
|
|
219
|
+
<div class="media-clip-point gcore-skin-text-color" data-clipstext="">•</div>
|
|
220
|
+
<div class="media-clip-text gcore-skin-text-color" data-clipstext=""></div>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
<div class="media-control-right-panel" data-media-control="">
|
|
228
|
+
|
|
229
|
+
<div class="media-control-multicamera" data-multicamera=""></div>
|
|
230
|
+
|
|
231
|
+
<div class="media-control-vr" data-vr=""></div>
|
|
232
|
+
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
</div>
|
|
236
|
+
<style>:root {}</style>"
|
|
237
|
+
`;
|
|
238
|
+
|
|
239
|
+
exports[`MediaControl > updateSettings > dvr > when enabled > should enable DVR controls 1`] = `
|
|
240
|
+
"<div class="media-control-background" data-background=""></div>
|
|
241
|
+
|
|
242
|
+
<div class="media-control-layer gcore-skin-bg-color" data-controls="">
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
<div class="media-control-left-panel" data-media-control="">
|
|
257
|
+
|
|
258
|
+
<div class="drawer-container" data-volume="">
|
|
259
|
+
<div class="drawer-icon-container" data-volume="">
|
|
260
|
+
<div class="drawer-icon media-control-icon gcore-skin-button-color" data-volume="">/assets/icons/new/volume-max.svg</div>
|
|
261
|
+
<span class="drawer-text" data-volume=""></span>
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<div class="bar-container" data-volume="">
|
|
265
|
+
<div class="bar-background" data-volume="">
|
|
266
|
+
<div class="bar-fill-1 gcore-skin-main-color" data-volume="" style=""></div>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="bar-scrubber" data-volume="" style="">
|
|
269
|
+
<div class="bar-scrubber-icon gcore-skin-main-color" data-volume=""></div>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<div class="media-control-indicator gcore-skin-text-color" data-position="">00:00</div>
|
|
276
|
+
|
|
277
|
+
<div class="media-control-indicator gcore-skin-text-color" data-duration="">00:00</div>
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
<div class="media-clip-container gcore-skin-text-color" data-clipstext="">
|
|
281
|
+
<div class="media-clip-point gcore-skin-text-color" data-clipstext="">•</div>
|
|
282
|
+
<div class="media-clip-text gcore-skin-text-color" data-clipstext=""></div>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
<div class="my-dvr-controls" data-dvr="">live</div></div>
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
<div class="media-control-right-panel" data-media-control="">
|
|
290
|
+
|
|
291
|
+
<div class="media-control-multicamera" data-multicamera=""></div>
|
|
292
|
+
|
|
293
|
+
<div class="media-control-vr" data-vr=""></div>
|
|
294
|
+
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
</div>
|
|
298
|
+
<style>:root {}</style>"
|
|
299
|
+
`;
|
package/src/testUtils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $, UICorePlugin } from '@clappr/core'
|
|
1
|
+
import { $, Playback, UICorePlugin } from '@clappr/core'
|
|
2
2
|
import Events from 'eventemitter3'
|
|
3
3
|
import { vi } from 'vitest'
|
|
4
4
|
/**
|
|
@@ -42,7 +42,7 @@ export class _MockPlayback extends Events {
|
|
|
42
42
|
exitPiP() {}
|
|
43
43
|
|
|
44
44
|
getPlaybackType() {
|
|
45
|
-
return
|
|
45
|
+
return Playback.LIVE
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
getStartTimeOffset() {
|
|
@@ -100,7 +100,7 @@ export function createMockCore(
|
|
|
100
100
|
...options,
|
|
101
101
|
},
|
|
102
102
|
configure: vi.fn(),
|
|
103
|
-
getPlaybackType: vi.fn(),
|
|
103
|
+
getPlaybackType: vi.fn().mockReturnValue(Playback.LIVE),
|
|
104
104
|
getPlugin: vi.fn(),
|
|
105
105
|
load: vi.fn(),
|
|
106
106
|
trigger: emitter.emit,
|
|
@@ -126,7 +126,9 @@ export function createMockPlayback(name = 'mock') {
|
|
|
126
126
|
return Object.assign(emitter, {
|
|
127
127
|
name,
|
|
128
128
|
currentLevel: -1,
|
|
129
|
+
el: document.createElement('video'),
|
|
129
130
|
dvrEnabled: false,
|
|
131
|
+
dvrInUse: false,
|
|
130
132
|
levels: [],
|
|
131
133
|
consent() {},
|
|
132
134
|
play() {},
|
|
@@ -138,7 +140,7 @@ export function createMockPlayback(name = 'mock') {
|
|
|
138
140
|
getDuration: vi.fn().mockImplementation(() => 100),
|
|
139
141
|
enterPiP: vi.fn(),
|
|
140
142
|
exitPiP: vi.fn(),
|
|
141
|
-
getPlaybackType: vi.fn().mockImplementation(() =>
|
|
143
|
+
getPlaybackType: vi.fn().mockImplementation(() => Playback.LIVE),
|
|
142
144
|
getStartTimeOffset: vi.fn().mockImplementation(() => 0),
|
|
143
145
|
getCurrentTime: vi.fn().mockImplementation(() => 0),
|
|
144
146
|
isHighDefinitionInUse: vi.fn().mockImplementation(() => false),
|
|
@@ -155,7 +157,7 @@ export function createMockPlayback(name = 'mock') {
|
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
export function createMockContainer(playback: any = createMockPlayback()) {
|
|
158
|
-
const el =
|
|
160
|
+
const el = playback.el
|
|
159
161
|
const emitter = new Events()
|
|
160
162
|
return Object.assign(emitter, {
|
|
161
163
|
el,
|
|
@@ -163,8 +165,9 @@ export function createMockContainer(playback: any = createMockPlayback()) {
|
|
|
163
165
|
$el: $(el),
|
|
164
166
|
getDuration: vi.fn().mockReturnValue(0),
|
|
165
167
|
getPlugin: vi.fn(),
|
|
166
|
-
getPlaybackType: vi.fn().mockReturnValue(
|
|
168
|
+
getPlaybackType: vi.fn().mockReturnValue(Playback.LIVE),
|
|
167
169
|
isDvrInUse: vi.fn().mockReturnValue(false),
|
|
170
|
+
isDvrEnabled: vi.fn().mockReturnValue(false),
|
|
168
171
|
isPlaying: vi.fn().mockReturnValue(false),
|
|
169
172
|
play: vi.fn(),
|
|
170
173
|
seek: vi.fn(),
|
|
@@ -187,10 +190,6 @@ export function createMockMediaControl(core: any) {
|
|
|
187
190
|
// @ts-ignore
|
|
188
191
|
mediaControl.putElement = vi.fn()
|
|
189
192
|
// @ts-ignore
|
|
190
|
-
mediaControl.
|
|
191
|
-
// @ts-ignore
|
|
192
|
-
mediaControl.getRightPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-right-panel'))
|
|
193
|
-
// @ts-ignore
|
|
194
|
-
mediaControl.getCenterPanel = vi.fn().mockImplementation(() => mediaControl.$el.find('.media-control-center-panel'))
|
|
193
|
+
mediaControl.toggleElement = vi.fn()
|
|
195
194
|
return mediaControl
|
|
196
195
|
}
|