@24i/bigscreen-sdk 1.0.6-alpha.2147 → 1.0.7-alpha.2158
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7-alpha.2158",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"homepage": "https://github.com/24i/smartapps-bigscreen-sdk#readme",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@24i/player-base": "6.10.0",
|
|
41
|
-
"@24i/smartapps-datalayer": "3.0.
|
|
41
|
+
"@24i/smartapps-datalayer": "3.0.3",
|
|
42
42
|
"@sentry/browser": "^7.12.1",
|
|
43
43
|
"@types/prop-types": "^15.7.5",
|
|
44
44
|
"@types/scheduler": "^0.16.2",
|
|
@@ -89,6 +89,7 @@ export class PlayerUI extends Component<Props>
|
|
|
89
89
|
onKeyPlay = () => {
|
|
90
90
|
if (this.seeking.isSeeking()) {
|
|
91
91
|
this.seeking.confirmSeek();
|
|
92
|
+
if (!this.isPlaying()) this.trigger(PlayerAction.PLAY);
|
|
92
93
|
return true;
|
|
93
94
|
}
|
|
94
95
|
if (!this.isPlaying()) {
|
|
@@ -102,6 +103,7 @@ export class PlayerUI extends Component<Props>
|
|
|
102
103
|
onKeyPause = () => {
|
|
103
104
|
if (this.seeking.isAutomaticallySeeking()) {
|
|
104
105
|
this.seeking.stopAutomaticSeek();
|
|
106
|
+
if (this.isPlaying()) this.trigger(PlayerAction.PAUSE);
|
|
105
107
|
return true;
|
|
106
108
|
}
|
|
107
109
|
if (this.isPlaying()) {
|
|
@@ -113,6 +115,11 @@ export class PlayerUI extends Component<Props>
|
|
|
113
115
|
};
|
|
114
116
|
|
|
115
117
|
onKeyPlayPause = () => {
|
|
118
|
+
if (this.seeking.isSeeking()) {
|
|
119
|
+
this.seeking.confirmSeek();
|
|
120
|
+
if (!this.isPlaying()) this.trigger(PlayerAction.PLAY);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
116
123
|
this.show();
|
|
117
124
|
if (this.isPlaying()) this.trigger(PlayerAction.PAUSE);
|
|
118
125
|
else this.trigger(PlayerAction.PLAY);
|
|
@@ -149,9 +156,9 @@ export class PlayerUI extends Component<Props>
|
|
|
149
156
|
return false;
|
|
150
157
|
};
|
|
151
158
|
|
|
152
|
-
getPlayer() {
|
|
159
|
+
getPlayer = () => {
|
|
153
160
|
return this.player!;
|
|
154
|
-
}
|
|
161
|
+
};
|
|
155
162
|
|
|
156
163
|
setPlayer(player: PlayerBase<any>) {
|
|
157
164
|
this.player = player;
|
|
@@ -12,6 +12,7 @@ const CONSECUTIVE_TIMEOUT = 500;
|
|
|
12
12
|
const FAST_TRESHOLD = 5;
|
|
13
13
|
const SLOW_TIME = 10000;
|
|
14
14
|
const FAST_TIME = 20000;
|
|
15
|
+
const SAFE_END_MARGIN = 10000;
|
|
15
16
|
const TO_PERCENT = 100;
|
|
16
17
|
|
|
17
18
|
type Props = PlayerUICommonProps;
|
|
@@ -86,11 +87,23 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
86
87
|
|
|
87
88
|
onRight = () => {
|
|
88
89
|
const { ui } = this.props;
|
|
90
|
+
const { seekTime } = ui.seeking;
|
|
91
|
+
if (seekTime == null && this.currentTime + SLOW_TIME >= this.duration) return true;
|
|
89
92
|
this.rightConsecutives += 1;
|
|
90
93
|
if (ui.seeking.isAutomaticallySeeking()) {
|
|
91
94
|
ui.seeking.stopAutomaticSeek();
|
|
92
95
|
}
|
|
93
|
-
|
|
96
|
+
const isFastSeeking = this.rightConsecutives >= FAST_TRESHOLD;
|
|
97
|
+
if (
|
|
98
|
+
(seekTime != null &&
|
|
99
|
+
(seekTime + SLOW_TIME >= this.duration - SAFE_END_MARGIN
|
|
100
|
+
|| (isFastSeeking && seekTime + FAST_TIME >= this.duration - SAFE_END_MARGIN)))
|
|
101
|
+
|| (seekTime == null && this.currentTime >= this.duration - SAFE_END_MARGIN)
|
|
102
|
+
) {
|
|
103
|
+
ui.seeking.setSeekTime(this.duration - SAFE_END_MARGIN);
|
|
104
|
+
} else {
|
|
105
|
+
ui.seeking.seekForward(isFastSeeking ? FAST_TIME : SLOW_TIME);
|
|
106
|
+
}
|
|
94
107
|
this.rightConsecutiveTimeout.set(() => {
|
|
95
108
|
this.rightConsecutives = 0;
|
|
96
109
|
}, CONSECUTIVE_TIMEOUT);
|
|
@@ -98,8 +111,10 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
98
111
|
};
|
|
99
112
|
|
|
100
113
|
onEnter = () => {
|
|
101
|
-
const { ui } = this.props;
|
|
102
|
-
|
|
114
|
+
const { ui: { seeking, getPlayer } } = this.props;
|
|
115
|
+
const player = getPlayer();
|
|
116
|
+
if (!player.playing) player.play();
|
|
117
|
+
return seeking.confirmSeek();
|
|
103
118
|
};
|
|
104
119
|
|
|
105
120
|
onSeekTimeUpdate = (seekTime: number) => {
|
|
@@ -110,6 +110,11 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
110
110
|
this.triggerEvent('seektimeupdate', this.seekTime!);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
setSeekTime = (seekTime: number) => {
|
|
114
|
+
this.seekTime = seekTime;
|
|
115
|
+
this.triggerEvent('seektimeupdate', this.seekTime!);
|
|
116
|
+
};
|
|
117
|
+
|
|
113
118
|
confirmSeek() {
|
|
114
119
|
if (!this.player) return false;
|
|
115
120
|
this.stopAutomaticSeek();
|
|
@@ -26,9 +26,17 @@ const getSeekingMock = (): jest.Mocked<IPlayerUI['seeking']> => ({
|
|
|
26
26
|
unsubscribeEvents: jest.fn(),
|
|
27
27
|
setPlayer: jest.fn(),
|
|
28
28
|
nullSeekTime: jest.fn(),
|
|
29
|
+
setSeekTime: jest.fn(),
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
const PLAYER_MOCK_DURATION = 60000;
|
|
33
|
+
|
|
34
|
+
export const getPlayerMock = (): PlayerBase<any> =>{
|
|
35
|
+
const playerMock = new PlayerBaseMock();
|
|
36
|
+
jest.spyOn(playerMock, 'duration', 'get').mockReturnValue(PLAYER_MOCK_DURATION);
|
|
37
|
+
|
|
38
|
+
return playerMock;
|
|
39
|
+
};
|
|
32
40
|
|
|
33
41
|
export const getUiMock = (): { ui: jest.Mocked<IPlayerUI> } => ({
|
|
34
42
|
ui: {
|
|
@@ -44,7 +44,7 @@ export const isElementWrappedBy = (
|
|
|
44
44
|
let wrapperElement: HTMLElement | null = null;
|
|
45
45
|
let condition: ((currentWrapper: HTMLElement) => boolean) | null = null;
|
|
46
46
|
if (typeof wrapperElementOrReferenceOrCondition === 'function') {
|
|
47
|
-
condition = wrapperElementOrReferenceOrCondition;
|
|
47
|
+
condition = wrapperElementOrReferenceOrCondition as (currentWrapper: HTMLElement) => boolean;
|
|
48
48
|
} else {
|
|
49
49
|
wrapperElement = unwrapReference(wrapperElementOrReferenceOrCondition);
|
|
50
50
|
if (!wrapperElement) return false;
|