@gcorevideo/player 2.21.4 → 2.22.0
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.ejs +1 -1
- 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 +1441 -1446
- package/dist/index.js +82 -79
- package/dist/plugins/index.css +1189 -1194
- package/dist/plugins/index.js +81 -76
- 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 +66 -38
- 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 +23 -25
- package/src/plugins/dvr-controls/__tests__/__snapshots__/DvrControls.test.ts.snap +8 -32
- package/src/plugins/media-control/MediaControl.ts +91 -51
- package/src/plugins/media-control/__tests__/MediaControl.test.ts +89 -0
- package/src/plugins/media-control/__tests__/__snapshots__/MediaControl.test.ts.snap +128 -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(),
|
|
@@ -786,7 +805,9 @@ export class MediaControl extends UICorePlugin {
|
|
|
786
805
|
}
|
|
787
806
|
|
|
788
807
|
private showVolumeBar() {
|
|
789
|
-
|
|
808
|
+
if (this.hideVolumeId) {
|
|
809
|
+
clearTimeout(this.hideVolumeId)
|
|
810
|
+
}
|
|
790
811
|
this.$volumeBarContainer?.removeClass('volume-bar-hide')
|
|
791
812
|
}
|
|
792
813
|
|
|
@@ -847,9 +868,9 @@ export class MediaControl extends UICorePlugin {
|
|
|
847
868
|
// default to 100%
|
|
848
869
|
this.currentSeekBarPercentage = 100
|
|
849
870
|
if (
|
|
850
|
-
this.
|
|
851
|
-
(this.
|
|
852
|
-
this.
|
|
871
|
+
this.core.activeContainer &&
|
|
872
|
+
(this.core.activeContainer.getPlaybackType() !== Playback.LIVE ||
|
|
873
|
+
this.core.activeContainer.isDvrInUse())
|
|
853
874
|
) {
|
|
854
875
|
this.currentSeekBarPercentage =
|
|
855
876
|
(this.currentPositionValue / this.currentDurationValue) * 100
|
|
@@ -885,21 +906,13 @@ export class MediaControl extends UICorePlugin {
|
|
|
885
906
|
let pos = (offsetX / this.$seekBarContainer.width()) * 100
|
|
886
907
|
|
|
887
908
|
pos = Math.min(100, Math.max(pos, 0))
|
|
888
|
-
this.
|
|
909
|
+
this.core.activeContainer && this.core.activeContainer.seekPercentage(pos)
|
|
889
910
|
|
|
890
911
|
this.setSeekPercentage(pos)
|
|
891
912
|
|
|
892
913
|
return false
|
|
893
914
|
}
|
|
894
915
|
|
|
895
|
-
private setKeepVisible() {
|
|
896
|
-
this.keepVisible = true
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
private resetKeepVisible() {
|
|
900
|
-
this.keepVisible = false
|
|
901
|
-
}
|
|
902
|
-
|
|
903
916
|
private setUserKeepVisible() {
|
|
904
917
|
this.userKeepVisible = true
|
|
905
918
|
}
|
|
@@ -998,11 +1011,19 @@ export class MediaControl extends UICorePlugin {
|
|
|
998
1011
|
this.core.activeContainer.settings,
|
|
999
1012
|
)
|
|
1000
1013
|
|
|
1014
|
+
// TODO make order controlled via CSS
|
|
1001
1015
|
newSettings.left = orderByOrderPattern(
|
|
1002
1016
|
[...newSettings.left, 'clipsText', 'volume'],
|
|
1003
1017
|
LEFT_ORDER,
|
|
1004
1018
|
)
|
|
1005
1019
|
|
|
1020
|
+
if (
|
|
1021
|
+
this.core.activePlayback.getPlaybackType() === Playback.LIVE &&
|
|
1022
|
+
this.core.activePlayback.dvrEnabled
|
|
1023
|
+
) {
|
|
1024
|
+
newSettings.left.push('dvr')
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1006
1027
|
// actual order of the items appear rendered is controlled by CSS
|
|
1007
1028
|
newSettings.right = [
|
|
1008
1029
|
'fullscreen',
|
|
@@ -1029,12 +1050,13 @@ export class MediaControl extends UICorePlugin {
|
|
|
1029
1050
|
removeArrayItem(newSettings.default, 'hd-indicator')
|
|
1030
1051
|
removeArrayItem(newSettings.left, 'hd-indicator')
|
|
1031
1052
|
|
|
1053
|
+
// TODO get from container's settings
|
|
1032
1054
|
if (this.core.activePlayback.name === 'html5_video') {
|
|
1033
1055
|
newSettings.seekEnabled = this.isSeekEnabledForHtml5Playback()
|
|
1034
1056
|
}
|
|
1035
1057
|
|
|
1036
1058
|
const settingsChanged =
|
|
1037
|
-
|
|
1059
|
+
serializeSettings(this.settings) !== serializeSettings(newSettings)
|
|
1038
1060
|
|
|
1039
1061
|
if (settingsChanged) {
|
|
1040
1062
|
this.settings = newSettings
|
|
@@ -1042,8 +1064,8 @@ export class MediaControl extends UICorePlugin {
|
|
|
1042
1064
|
}
|
|
1043
1065
|
}
|
|
1044
1066
|
|
|
1045
|
-
private
|
|
1046
|
-
|
|
1067
|
+
private onHdUpdate(isHD: boolean) {
|
|
1068
|
+
// TODO render?
|
|
1047
1069
|
}
|
|
1048
1070
|
|
|
1049
1071
|
private createCachedElements() {
|
|
@@ -1119,11 +1141,11 @@ export class MediaControl extends UICorePlugin {
|
|
|
1119
1141
|
}
|
|
1120
1142
|
|
|
1121
1143
|
putElement(name: MediaControlElement, element: HTMLElement) {
|
|
1122
|
-
const panel = this.getElementLocation(name)
|
|
1144
|
+
const panel = this.getElementLocation(name)
|
|
1123
1145
|
trace(`${T} putElement`, { name, panel: !!panel })
|
|
1124
1146
|
if (panel) {
|
|
1125
1147
|
const current = panel.find(`[data-${name}]`)
|
|
1126
|
-
element.setAttribute(`data-${name}`,
|
|
1148
|
+
element.setAttribute(`data-${name}`, '')
|
|
1127
1149
|
// TODO test
|
|
1128
1150
|
if (current.length) {
|
|
1129
1151
|
if (current[0] === element) {
|
|
@@ -1137,22 +1159,23 @@ export class MediaControl extends UICorePlugin {
|
|
|
1137
1159
|
}
|
|
1138
1160
|
|
|
1139
1161
|
/**
|
|
1140
|
-
*
|
|
1141
|
-
* @
|
|
1162
|
+
* Toggle the visibility of a media control element
|
|
1163
|
+
* @param name - The name of the media control element
|
|
1164
|
+
* @param show - Whether to show or hide the element
|
|
1142
1165
|
*/
|
|
1143
|
-
|
|
1166
|
+
toggleElement(name: MediaControlElement, show: boolean) {
|
|
1167
|
+
this.$el.find(`[data-${name}]`).toggle(show)
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
private getRightPanel() {
|
|
1144
1171
|
return this.$el.find('.media-control-right-panel')
|
|
1145
1172
|
}
|
|
1146
1173
|
|
|
1147
|
-
|
|
1148
|
-
* Get the left panel area to append custom elements to
|
|
1149
|
-
* @returns ZeptoSelector of the left panel element
|
|
1150
|
-
*/
|
|
1151
|
-
getLeftPanel() {
|
|
1174
|
+
private getLeftPanel() {
|
|
1152
1175
|
return this.$el.find('.media-control-left-panel')
|
|
1153
1176
|
}
|
|
1154
1177
|
|
|
1155
|
-
getCenterPanel() {
|
|
1178
|
+
private getCenterPanel() {
|
|
1156
1179
|
return this.$el.find('.media-control-center-panel')
|
|
1157
1180
|
}
|
|
1158
1181
|
|
|
@@ -1389,7 +1412,6 @@ export class MediaControl extends UICorePlugin {
|
|
|
1389
1412
|
}, 0)
|
|
1390
1413
|
|
|
1391
1414
|
this.parseColors()
|
|
1392
|
-
this.highDefinitionUpdate(this.isHD)
|
|
1393
1415
|
|
|
1394
1416
|
this.core.$el.append(this.el)
|
|
1395
1417
|
|
|
@@ -1484,18 +1506,36 @@ export class MediaControl extends UICorePlugin {
|
|
|
1484
1506
|
|
|
1485
1507
|
private getElementLocation(name: MediaControlElement) {
|
|
1486
1508
|
if (this.settings.right?.includes(name)) {
|
|
1487
|
-
return this.getRightPanel()
|
|
1509
|
+
return this.getRightPanel()
|
|
1488
1510
|
}
|
|
1489
1511
|
if (this.settings.left?.includes(name)) {
|
|
1490
|
-
return this.getLeftPanel()
|
|
1512
|
+
return this.getLeftPanel()
|
|
1491
1513
|
}
|
|
1492
1514
|
if (this.settings.default?.includes(name)) {
|
|
1493
|
-
return this.getCenterPanel()
|
|
1515
|
+
return this.getCenterPanel()
|
|
1516
|
+
}
|
|
1517
|
+
return null
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
private onDvrStateChanged(dvrInUse: boolean) {
|
|
1521
|
+
if (dvrInUse) {
|
|
1522
|
+
this.$el.addClass('dvr')
|
|
1523
|
+
} else {
|
|
1524
|
+
this.$el.removeClass('dvr')
|
|
1494
1525
|
}
|
|
1495
|
-
return null;
|
|
1496
1526
|
}
|
|
1497
1527
|
}
|
|
1498
1528
|
|
|
1499
1529
|
MediaControl.extend = function (properties) {
|
|
1500
1530
|
return extend(MediaControl, properties)
|
|
1501
1531
|
}
|
|
1532
|
+
|
|
1533
|
+
function serializeSettings(s: MediaControlSettings) {
|
|
1534
|
+
return s.left
|
|
1535
|
+
.slice()
|
|
1536
|
+
.sort()
|
|
1537
|
+
.concat(s.right.slice().sort())
|
|
1538
|
+
.concat(s.default.slice().sort())
|
|
1539
|
+
.concat([s.seekEnabled as any])
|
|
1540
|
+
.join(',')
|
|
1541
|
+
}
|
|
@@ -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,131 @@ 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
|
+
<button type="button" class="media-control-button media-control-icon gcore-skin-button-color paused" data-playpause="" aria-label="playpause">/assets/icons/new/play.svg</button>
|
|
197
|
+
|
|
198
|
+
<div class="drawer-container" data-volume="">
|
|
199
|
+
<div class="drawer-icon-container" data-volume="">
|
|
200
|
+
<div class="drawer-icon media-control-icon gcore-skin-button-color" data-volume="">/assets/icons/new/volume-max.svg</div>
|
|
201
|
+
<span class="drawer-text" data-volume=""></span>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div class="bar-container" data-volume="">
|
|
205
|
+
<div class="bar-background" data-volume="">
|
|
206
|
+
<div class="bar-fill-1 gcore-skin-main-color" data-volume="" style=""></div>
|
|
207
|
+
</div>
|
|
208
|
+
<div class="bar-scrubber" data-volume="" style="">
|
|
209
|
+
<div class="bar-scrubber-icon gcore-skin-main-color" data-volume=""></div>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<div class="media-control-indicator gcore-skin-text-color" data-position="">00:00</div>
|
|
216
|
+
|
|
217
|
+
<div class="media-control-indicator gcore-skin-text-color" data-duration="">00:00</div>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
<div class="media-clip-container gcore-skin-text-color" data-clipstext="">
|
|
221
|
+
<div class="media-clip-point gcore-skin-text-color" data-clipstext="">•</div>
|
|
222
|
+
<div class="media-clip-text gcore-skin-text-color" data-clipstext=""></div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
<div class="media-control-right-panel" data-media-control="">
|
|
230
|
+
|
|
231
|
+
<div class="media-control-multicamera" data-multicamera=""></div>
|
|
232
|
+
|
|
233
|
+
<div class="media-control-vr" data-vr=""></div>
|
|
234
|
+
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
</div>
|
|
238
|
+
<style>:root {}</style>"
|
|
239
|
+
`;
|
|
240
|
+
|
|
241
|
+
exports[`MediaControl > updateSettings > dvr > when enabled > should enable DVR controls 1`] = `
|
|
242
|
+
"<div class="media-control-background" data-background=""></div>
|
|
243
|
+
|
|
244
|
+
<div class="media-control-layer gcore-skin-bg-color" data-controls="">
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
<div class="media-control-left-panel" data-media-control="">
|
|
259
|
+
|
|
260
|
+
<button type="button" class="media-control-button media-control-icon gcore-skin-button-color paused" data-playpause="" aria-label="playpause">/assets/icons/new/play.svg</button>
|
|
261
|
+
|
|
262
|
+
<div class="drawer-container" data-volume="">
|
|
263
|
+
<div class="drawer-icon-container" data-volume="">
|
|
264
|
+
<div class="drawer-icon media-control-icon gcore-skin-button-color" data-volume="">/assets/icons/new/volume-max.svg</div>
|
|
265
|
+
<span class="drawer-text" data-volume=""></span>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div class="bar-container" data-volume="">
|
|
269
|
+
<div class="bar-background" data-volume="">
|
|
270
|
+
<div class="bar-fill-1 gcore-skin-main-color" data-volume="" style=""></div>
|
|
271
|
+
</div>
|
|
272
|
+
<div class="bar-scrubber" data-volume="" style="">
|
|
273
|
+
<div class="bar-scrubber-icon gcore-skin-main-color" data-volume=""></div>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
<div class="media-control-indicator gcore-skin-text-color" data-position="">00:00</div>
|
|
280
|
+
|
|
281
|
+
<div class="media-control-indicator gcore-skin-text-color" data-duration="">00:00</div>
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
<div class="media-clip-container gcore-skin-text-color" data-clipstext="">
|
|
285
|
+
<div class="media-clip-point gcore-skin-text-color" data-clipstext="">•</div>
|
|
286
|
+
<div class="media-clip-text gcore-skin-text-color" data-clipstext=""></div>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
<div class="my-dvr-controls" data-dvr="">live</div></div>
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
<div class="media-control-right-panel" data-media-control="">
|
|
294
|
+
|
|
295
|
+
<div class="media-control-multicamera" data-multicamera=""></div>
|
|
296
|
+
|
|
297
|
+
<div class="media-control-vr" data-vr=""></div>
|
|
298
|
+
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
</div>
|
|
302
|
+
<style>:root {}</style>"
|
|
303
|
+
`;
|
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
|
}
|