@24i/bigscreen-sdk 1.0.19-alpha.2340 → 1.0.19-bs-player.2380
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 +4 -4
- package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
- package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
- package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +1 -1
- package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +12 -0
- package/packages/driver-androidtv/src/types.ts +40 -0
- package/packages/gallup/src/Gallup.ts +3 -3
- package/packages/player-ui/src/CurrentTime.tsx +2 -2
- package/packages/player-ui/src/Duration.tsx +2 -2
- package/packages/player-ui/src/PlayerUI.tsx +4 -4
- package/packages/player-ui/src/RemainingTime.tsx +2 -2
- package/packages/player-ui/src/Seekbar.tsx +3 -3
- package/packages/player-ui/src/Seeking.ts +4 -4
- package/packages/player-ui/src/Subtitles.tsx +2 -2
- package/packages/player-ui/src/mocks.ts +12 -4
- package/packages/player-ui/src/types.ts +2 -2
- package/packages/router/src/Route.tsx +10 -27
- package/packages/router/src/Router.tsx +59 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.19-
|
|
3
|
+
"version": "1.0.19-bs-player.2380",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@24i/appstage-shared-analytics": "1.0.16-alpha.58",
|
|
41
41
|
"@24i/appstage-shared-events-manager": "1.0.7",
|
|
42
42
|
"@24i/appstage-shared-perf-utils": "1.0.5",
|
|
43
|
-
"@24i/
|
|
44
|
-
"@24i/smartapps-datalayer": "3.0.8
|
|
43
|
+
"@24i/bigscreen-players-engine-base": "0.1.5",
|
|
44
|
+
"@24i/smartapps-datalayer": "3.0.8",
|
|
45
45
|
"@sentry/browser": "7.35.0",
|
|
46
46
|
"@sentry/types": "7.35.0",
|
|
47
47
|
"@types/gtag.js": "^0.0.12",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@24i/bigscreen-sdk": "file:.",
|
|
56
56
|
"@24i/eslint-config-smartapps-bigscreen-linters": "file:./libs/linters",
|
|
57
57
|
"@24i/smartapps-bigscreen-changelog-generator": "0.17.0",
|
|
58
|
-
"@babel/core": "^7.
|
|
58
|
+
"@babel/core": "^7.22.1",
|
|
59
59
|
"@babel/preset-env": "^7.22.4",
|
|
60
60
|
"@types/fs-extra": "^11.0.1",
|
|
61
61
|
"@types/inquirer": "^9.0.3",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path='./__external__/Adobe/Adobe.d.ts' />
|
|
2
|
-
import { IErrorEvent, PlayerBase } from '@24i/
|
|
2
|
+
import { IErrorEvent, PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
3
3
|
import { time } from '@24i/bigscreen-sdk/time';
|
|
4
4
|
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
5
5
|
import { va as Adobe } from './__external__/Adobe/MediaSDK.min';
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = void> {
|
|
16
16
|
static StreamType = Adobe.MediaHeartbeat.StreamType;
|
|
17
17
|
|
|
18
|
-
private player?: PlayerBase
|
|
18
|
+
private player?: PlayerBase;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Heartbeat configuration object
|
|
@@ -32,7 +32,7 @@ export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = voi
|
|
|
32
32
|
* @param config - Heartbeat configuration object
|
|
33
33
|
* @param player - 24i universal player instance
|
|
34
34
|
*/
|
|
35
|
-
constructor(config: HeartbeatConfig, player?: PlayerBase
|
|
35
|
+
constructor(config: HeartbeatConfig, player?: PlayerBase) {
|
|
36
36
|
if (!window.s || !AppMeasurement) throw new Error('Missing Adobe Launch library!');
|
|
37
37
|
this.config = config;
|
|
38
38
|
this.player = player;
|
|
@@ -67,10 +67,10 @@ export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = voi
|
|
|
67
67
|
return {
|
|
68
68
|
getCurrentPlaybackTime: () => {
|
|
69
69
|
if (!this.player) return 0;
|
|
70
|
-
const { currentTime } = this.player.
|
|
70
|
+
const { currentTime } = this.player.mediaInfo || {};
|
|
71
71
|
if (this.player.live) {
|
|
72
72
|
try {
|
|
73
|
-
const { programEnd = NaN } = this.player.
|
|
73
|
+
const { programEnd = NaN } = this.player.metadata;
|
|
74
74
|
return Math.floor((programEnd - currentTime) / SECOND_IN_MS)
|
|
75
75
|
|| time.getCurrentUnixTime();
|
|
76
76
|
} catch (e) {
|
|
@@ -81,7 +81,7 @@ export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = voi
|
|
|
81
81
|
},
|
|
82
82
|
getQoSObject: () => {
|
|
83
83
|
if (!this.player) return Adobe.MediaHeartbeat.createQoSObject();
|
|
84
|
-
const { bitrate, droppedVideoFrames } = this.player.
|
|
84
|
+
const { bitrate, droppedVideoFrames } = this.player.mediaInfo || {};
|
|
85
85
|
return Adobe.MediaHeartbeat.createQoSObject(
|
|
86
86
|
bitrate, undefined, undefined, droppedVideoFrames,
|
|
87
87
|
);
|
|
@@ -89,7 +89,7 @@ export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = voi
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
private attachPlayerListeners(player: PlayerBase
|
|
92
|
+
private attachPlayerListeners(player: PlayerBase) {
|
|
93
93
|
player.addEventListener('play', this.onPlay);
|
|
94
94
|
player.addEventListener('pause', this.onPause);
|
|
95
95
|
player.addEventListener('ended', this.onEnded);
|
|
@@ -98,7 +98,7 @@ export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = voi
|
|
|
98
98
|
player.addEventListener('error', this.onError);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
private dettachPlayerListeners(player: PlayerBase
|
|
101
|
+
private dettachPlayerListeners(player: PlayerBase) {
|
|
102
102
|
player.removeEventListener('play', this.onPlay);
|
|
103
103
|
player.removeEventListener('pause', this.onPause);
|
|
104
104
|
player.removeEventListener('ended', this.onEnded);
|
|
@@ -143,7 +143,7 @@ export class AdobeHeartbeat<CustomMetadata extends CustomerMetadata | void = voi
|
|
|
143
143
|
* this will replace the old one.
|
|
144
144
|
* @param player - 24i universal player instance
|
|
145
145
|
*/
|
|
146
|
-
attachPlayer(player: PlayerBase
|
|
146
|
+
attachPlayer(player: PlayerBase) {
|
|
147
147
|
if (this.player) this.dettachPlayerListeners(this.player);
|
|
148
148
|
this.player = player;
|
|
149
149
|
if (this.player) this.attachPlayerListeners(this.player);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
2
|
import { DISPLAY_NONE, getDisplayToggler } from '@24i/bigscreen-sdk/utils';
|
|
3
3
|
import { createInterval } from '@24i/bigscreen-sdk/utils/timers';
|
|
4
|
-
import { IMediaInfo, PlayerBase } from '@24i/
|
|
4
|
+
import { IMediaInfo, PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
5
5
|
import { IDeveloperTool } from '../IDeveloperTool';
|
|
6
6
|
import { MEDIA_INFO_DESCRIPTION, MediaInfo } from './constants';
|
|
7
7
|
|
|
8
8
|
export type Props = {
|
|
9
|
-
playerInstance?: PlayerBase
|
|
9
|
+
playerInstance?: PlayerBase;
|
|
10
10
|
updateInterval?: number;
|
|
11
11
|
onClose?: () => void;
|
|
12
12
|
};
|
|
@@ -16,7 +16,7 @@ export class PlayerDebugWindow extends Component<Props> implements IDeveloperToo
|
|
|
16
16
|
|
|
17
17
|
div = createRef<HTMLDivElement>();
|
|
18
18
|
|
|
19
|
-
playerInstance: PlayerBase
|
|
19
|
+
playerInstance: PlayerBase | null = null;
|
|
20
20
|
|
|
21
21
|
interval = createInterval();
|
|
22
22
|
|
|
@@ -34,12 +34,12 @@ export class PlayerDebugWindow extends Component<Props> implements IDeveloperToo
|
|
|
34
34
|
if (playerInstance) this.setPlayerInstance(playerInstance);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
setPlayerInstance(playerInstance: PlayerBase
|
|
37
|
+
setPlayerInstance(playerInstance: PlayerBase) {
|
|
38
38
|
this.playerInstance = playerInstance;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
getMediaInfo() {
|
|
42
|
-
return this.playerInstance?.
|
|
42
|
+
return this.playerInstance?.mediaInfo || {};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
getFormattedValue(item: MediaInfo, value: any) {
|
|
@@ -4,7 +4,7 @@ import { IStorage } from '@24i/bigscreen-sdk/storage/interface';
|
|
|
4
4
|
import { getUsedJSHeapSize, getTotalJSHeapSize } from '@24i/bigscreen-sdk/utils/memoryInfo';
|
|
5
5
|
import { ipify } from '@24i/bigscreen-sdk/ipify';
|
|
6
6
|
import { map } from '@24i/bigscreen-sdk/perf-utils/array';
|
|
7
|
-
import { PlayerBase } from '@24i/
|
|
7
|
+
import { PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
8
8
|
import { hasEMESupport, getListOfSupportedDRM } from './utils/emeSupport';
|
|
9
9
|
import {
|
|
10
10
|
hasEMESupport as hasEMESupport01b,
|
|
@@ -14,5 +14,17 @@ export const mockJavaScriptBridge: IJavaScriptBridge = {
|
|
|
14
14
|
})
|
|
15
15
|
),
|
|
16
16
|
bridgeJavaScriptToAndroid_Back: () => {},
|
|
17
|
+
bridgeJavaScriptToAndroid_StopVideo: () => {},
|
|
18
|
+
bridgeJavaScriptToAndroid_FullScreenVideo: () => {},
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
bridgeJavaScriptToAndroid_SetVideoPath: (url: string) => {},
|
|
21
|
+
bridgeJavaScriptToAndroid_IsPlaying: () => true,
|
|
22
|
+
bridgeJavaScriptToAndroid_PauseVideo: () => {},
|
|
23
|
+
bridgeJavaScriptToAndroid_PlayVideo: () => {},
|
|
24
|
+
bridgeJavaScriptToAndroid_IsLive: () => false,
|
|
25
|
+
bridgeJavaScriptToAndroid_GetCurrentTime: () => Date.now(),
|
|
26
|
+
bridgeJavaScriptToAndroid_GetTotalTime: () => Date.now(),
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
bridgeJavaScriptToAndroid_SeekTo: (milliseconds: number) => {},
|
|
17
29
|
},
|
|
18
30
|
};
|
|
@@ -11,6 +11,46 @@ interface JavaScriptBridge {
|
|
|
11
11
|
* It simulates a native Android back press.
|
|
12
12
|
*/
|
|
13
13
|
bridgeJavaScriptToAndroid_Back: () => void,
|
|
14
|
+
/**
|
|
15
|
+
* It simulates a native Android stop button press.
|
|
16
|
+
*/
|
|
17
|
+
bridgeJavaScriptToAndroid_StopVideo: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* It sets the video to fullscreen mode
|
|
20
|
+
*/
|
|
21
|
+
bridgeJavaScriptToAndroid_FullScreenVideo: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* It sets the video url
|
|
24
|
+
*/
|
|
25
|
+
bridgeJavaScriptToAndroid_SetVideoPath: (url: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* It returns whether the video is playing
|
|
28
|
+
*/
|
|
29
|
+
bridgeJavaScriptToAndroid_IsPlaying: () => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* It pauses the video
|
|
32
|
+
*/
|
|
33
|
+
bridgeJavaScriptToAndroid_PauseVideo: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* It plays the video
|
|
36
|
+
*/
|
|
37
|
+
bridgeJavaScriptToAndroid_PlayVideo: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* It returns whether the video is live
|
|
40
|
+
*/
|
|
41
|
+
bridgeJavaScriptToAndroid_IsLive: () => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* It returns current time of currently played video
|
|
44
|
+
*/
|
|
45
|
+
bridgeJavaScriptToAndroid_GetCurrentTime: () => number;
|
|
46
|
+
/**
|
|
47
|
+
* It returns total duration of the video
|
|
48
|
+
*/
|
|
49
|
+
bridgeJavaScriptToAndroid_GetTotalTime: () => number;
|
|
50
|
+
/**
|
|
51
|
+
* It seeks the video to specified milliseconds
|
|
52
|
+
*/
|
|
53
|
+
bridgeJavaScriptToAndroid_SeekTo: (milliseconds: number) => void;
|
|
14
54
|
}
|
|
15
55
|
|
|
16
56
|
export type DeviceInfo = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerBase } from '@24i/
|
|
1
|
+
import { PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
2
2
|
import './__external__/SpringStreams';
|
|
3
3
|
|
|
4
4
|
const SECOND_IN_MS = 1000;
|
|
@@ -16,7 +16,7 @@ export class Gallup {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(
|
|
18
18
|
siteCode: string,
|
|
19
|
-
private readonly player: PlayerBase
|
|
19
|
+
private readonly player: PlayerBase,
|
|
20
20
|
private readonly playerName: string,
|
|
21
21
|
) {
|
|
22
22
|
this.sensors = new SpringStreams(siteCode);
|
|
@@ -67,7 +67,7 @@ export class Gallup {
|
|
|
67
67
|
getPosition: () => Math.floor(player.currentTime / SECOND_IN_MS),
|
|
68
68
|
getMeta: () => {
|
|
69
69
|
const { width, height } = window.screen;
|
|
70
|
-
const { playerVersion } = player.
|
|
70
|
+
const { playerVersion } = player.mediaInfo;
|
|
71
71
|
return {
|
|
72
72
|
pl: playerName,
|
|
73
73
|
plv: playerVersion || '',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { ITimeUpdateEvent } from '@24i/
|
|
2
|
+
import { ITimeUpdateEvent } from '@24i/bigscreen-players-engine-base';
|
|
3
3
|
import { PlayerTime } from './PlayerTime';
|
|
4
4
|
import { PlayerUICommonProps, PlayerUITimeProps } from './types';
|
|
5
5
|
|
|
@@ -26,7 +26,7 @@ export class CurrentTime extends Component<Props> {
|
|
|
26
26
|
const playerInstance = ui.getPlayer();
|
|
27
27
|
this.isLive = playerInstance.live;
|
|
28
28
|
playerInstance.addEventListener('timeupdate', this.onTimeUpdate);
|
|
29
|
-
const { programStart = 0 } = playerInstance.
|
|
29
|
+
const { programStart = 0 } = playerInstance.metadata || {};
|
|
30
30
|
this.liveStartTime = programStart || Date.now();
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { IDurationChangeEvent } from '@24i/
|
|
2
|
+
import { IDurationChangeEvent } from '@24i/bigscreen-players-engine-base';
|
|
3
3
|
import { PlayerTime } from './PlayerTime';
|
|
4
4
|
import { PlayerUICommonProps, PlayerUITimeProps } from './types';
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ export class Duration extends Component<Props> {
|
|
|
20
20
|
componentDidMount() {
|
|
21
21
|
const { ui } = this.props;
|
|
22
22
|
const playerInstance = ui.getPlayer();
|
|
23
|
-
const { programStart = 0, programEnd = 0 } = playerInstance.
|
|
23
|
+
const { programStart = 0, programEnd = 0 } = playerInstance.metadata || {};
|
|
24
24
|
const isLive = playerInstance.live;
|
|
25
25
|
if (isLive && programStart < programEnd) {
|
|
26
26
|
this.time.current!.updateTime(programEnd - programStart);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { PlayerBase } from '@24i/
|
|
2
|
+
import { PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
3
3
|
import { FF, REW, switchByKey } from '@24i/bigscreen-sdk/device/keymap';
|
|
4
4
|
import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
|
|
5
5
|
import {
|
|
@@ -16,7 +16,7 @@ export type PlayerUIState = {
|
|
|
16
16
|
|
|
17
17
|
type Props = {
|
|
18
18
|
children: (state: PlayerUIState) => JSX.Element | JSX.Element[] | string | null | null[],
|
|
19
|
-
player: PlayerBase
|
|
19
|
+
player: PlayerBase,
|
|
20
20
|
timeout?: number,
|
|
21
21
|
className?: string,
|
|
22
22
|
hidden?: boolean,
|
|
@@ -44,7 +44,7 @@ export class PlayerUI extends Component<Props>
|
|
|
44
44
|
// eslint-disable-next-line react/destructuring-assignment
|
|
45
45
|
divDisplay: IDisplayToggler = getDisplayToggler(this.div, this.props.hidden);
|
|
46
46
|
|
|
47
|
-
player: PlayerBase
|
|
47
|
+
player: PlayerBase | null = null;
|
|
48
48
|
|
|
49
49
|
static defaultProps = {
|
|
50
50
|
timeout: 5000,
|
|
@@ -175,7 +175,7 @@ export class PlayerUI extends Component<Props>
|
|
|
175
175
|
|
|
176
176
|
getPlayer = () => this.player!;
|
|
177
177
|
|
|
178
|
-
setPlayer(player: PlayerBase
|
|
178
|
+
setPlayer(player: PlayerBase) {
|
|
179
179
|
this.player = player;
|
|
180
180
|
if (this.seeking) this.seeking.setPlayer(player);
|
|
181
181
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
|
-
import { IDurationChangeEvent, ITimeUpdateEvent } from '@24i/
|
|
2
|
+
import { IDurationChangeEvent, ITimeUpdateEvent } from '@24i/bigscreen-players-engine-base';
|
|
3
3
|
import { PlayerTime } from './PlayerTime';
|
|
4
4
|
import { PlayerUICommonProps, PlayerUITimeProps } from './types';
|
|
5
5
|
|
|
@@ -32,7 +32,7 @@ export class RemainingTime extends Component<Props> {
|
|
|
32
32
|
this.duration = playerInstance.duration;
|
|
33
33
|
playerInstance.addEventListener('timeupdate', this.onTimeUpdate);
|
|
34
34
|
playerInstance.addEventListener('durationchange', this.onDurationChange);
|
|
35
|
-
const { programEnd = 0 } = playerInstance.
|
|
35
|
+
const { programEnd = 0 } = playerInstance.metadata || {};
|
|
36
36
|
this.liveEndTime = programEnd || Date.now();
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, createRef } from '@24i/bigscreen-sdk/jsx';
|
|
2
2
|
import { IFocusable } from '@24i/bigscreen-sdk/focus';
|
|
3
3
|
import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
|
|
4
|
-
import { ITimeUpdateEvent, IDurationChangeEvent } from '@24i/
|
|
4
|
+
import { ITimeUpdateEvent, IDurationChangeEvent } from '@24i/bigscreen-players-engine-base';
|
|
5
5
|
import { createTimeout } from '@24i/bigscreen-sdk/utils/timers';
|
|
6
6
|
import { switchByKey } from '@24i/bigscreen-sdk/device/keymap';
|
|
7
7
|
import { getDisplayToggler } from '@24i/bigscreen-sdk/utils/displayToggler';
|
|
@@ -195,7 +195,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
195
195
|
const { ui } = this.props;
|
|
196
196
|
const player = ui.getPlayer();
|
|
197
197
|
if (player.live) {
|
|
198
|
-
const { programStart = 0, programEnd = 0 } = player.
|
|
198
|
+
const { programStart = 0, programEnd = 0 } = player.metadata;
|
|
199
199
|
this.duration = programEnd - programStart || Date.now();
|
|
200
200
|
} else {
|
|
201
201
|
this.duration = duration;
|
|
@@ -207,7 +207,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
207
207
|
const { ui } = this.props;
|
|
208
208
|
const player = ui.getPlayer();
|
|
209
209
|
if (player.live) {
|
|
210
|
-
const { programStart = 0, programEnd = 0 } = player.
|
|
210
|
+
const { programStart = 0, programEnd = 0 } = player.metadata;
|
|
211
211
|
const { start, end } = player.seekableRange;
|
|
212
212
|
return getLiveProgressBasedOnCurrentTime(
|
|
213
213
|
programStart,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IEvents, EventMapType, EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
2
2
|
import { createInterval, createTimeout } from '@24i/bigscreen-sdk/utils/timers';
|
|
3
|
-
import { PlayerBase } from '@24i/
|
|
3
|
+
import { PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
4
4
|
|
|
5
5
|
const DEFAULT_SEEK_TIME = 10000;
|
|
6
6
|
const FAST_SEEK_TIME = 30000;
|
|
@@ -26,7 +26,7 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
26
26
|
|
|
27
27
|
automaticSeekInterval = createInterval();
|
|
28
28
|
|
|
29
|
-
player: PlayerBase
|
|
29
|
+
player: PlayerBase | null;
|
|
30
30
|
|
|
31
31
|
isAutomaticallySeekingForward = false;
|
|
32
32
|
|
|
@@ -40,7 +40,7 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
40
40
|
|
|
41
41
|
rewConsecutiveTimeout = createTimeout();
|
|
42
42
|
|
|
43
|
-
constructor(player: PlayerBase
|
|
43
|
+
constructor(player: PlayerBase | null = null) {
|
|
44
44
|
this.player = player;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
52
52
|
this.player!.removeEventListener('seeked', this.nullSeekTime);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
setPlayer(player: PlayerBase
|
|
55
|
+
setPlayer(player: PlayerBase) {
|
|
56
56
|
this.player = player;
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PlayerBase, ITimeUpdateEvent } from '@24i/
|
|
1
|
+
import { PlayerBase, ITimeUpdateEvent } from '@24i/bigscreen-players-engine-base';
|
|
2
2
|
import { Component, createRef, DeclareProps, setText } from '@24i/bigscreen-sdk/jsx';
|
|
3
3
|
import { getDisplayToggler } from '@24i/bigscreen-sdk/utils';
|
|
4
4
|
import { SubtitlesType } from '@24i/smartapps-datalayer/src/models';
|
|
5
5
|
import { timeToMs } from './timeUtils';
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
|
-
player: PlayerBase
|
|
8
|
+
player: PlayerBase,
|
|
9
9
|
className?: string,
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerBase, PlayerBaseMock } from '@24i/
|
|
1
|
+
import { IPlayerProperties, PlayerBase, PlayerBaseMock } from '@24i/bigscreen-players-engine-base';
|
|
2
2
|
import { EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
3
3
|
import { IPlayerUIWithSeeking } from './types';
|
|
4
4
|
|
|
@@ -35,8 +35,16 @@ const getSeekingMock = (): jest.Mocked<IPlayerUIWithSeeking['seeking']> => ({
|
|
|
35
35
|
|
|
36
36
|
const PLAYER_MOCK_DURATION = 60000;
|
|
37
37
|
|
|
38
|
-
export const getPlayerMock = (): PlayerBase
|
|
39
|
-
const
|
|
38
|
+
export const getPlayerMock = (): PlayerBase => {
|
|
39
|
+
const initialConfig: IPlayerProperties = {
|
|
40
|
+
source: {
|
|
41
|
+
url: '',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const parentElement = document.createElement('div');
|
|
45
|
+
|
|
46
|
+
const playerMock = new PlayerBaseMock(initialConfig, parentElement);
|
|
47
|
+
playerMock.source = initialConfig.source;
|
|
40
48
|
jest.spyOn(playerMock, 'duration', 'get').mockReturnValue(PLAYER_MOCK_DURATION);
|
|
41
49
|
|
|
42
50
|
return playerMock;
|
|
@@ -44,7 +52,7 @@ export const getPlayerMock = (): PlayerBase<any> => {
|
|
|
44
52
|
|
|
45
53
|
export const getUiMock = (): { ui: jest.Mocked<IPlayerUIWithSeeking> } => ({
|
|
46
54
|
ui: {
|
|
47
|
-
getPlayer: jest.fn((): PlayerBase
|
|
55
|
+
getPlayer: jest.fn((): PlayerBase => getPlayerMock()),
|
|
48
56
|
heartbeat: jest.fn(),
|
|
49
57
|
trigger: jest.fn(),
|
|
50
58
|
isPlaying: jest.fn(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerBase } from '@24i/
|
|
1
|
+
import { PlayerBase } from '@24i/bigscreen-players-engine-base';
|
|
2
2
|
import { Seeking } from './Seeking';
|
|
3
3
|
|
|
4
4
|
export enum PlayerAction {
|
|
@@ -21,7 +21,7 @@ export interface ActionsWithPayloadMap {
|
|
|
21
21
|
|
|
22
22
|
export interface IPlayerUI {
|
|
23
23
|
seeking?: Seeking;
|
|
24
|
-
getPlayer: () => PlayerBase
|
|
24
|
+
getPlayer: () => PlayerBase,
|
|
25
25
|
disableHiding: () => void,
|
|
26
26
|
enableHiding: () => void,
|
|
27
27
|
disableSeeking: () => void,
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Component,
|
|
4
4
|
createRef,
|
|
5
5
|
detachNode,
|
|
6
|
+
Reference,
|
|
6
7
|
replaceNode,
|
|
7
8
|
} from '@24i/bigscreen-sdk/jsx';
|
|
8
9
|
import { filter, forEach } from '@24i/bigscreen-sdk/perf-utils/array';
|
|
@@ -13,9 +14,9 @@ import { IRoute, RouteParams } from './types';
|
|
|
13
14
|
|
|
14
15
|
type Props = {
|
|
15
16
|
path: string,
|
|
17
|
+
domParent?: Reference<HTMLElement>;
|
|
16
18
|
regexpPath?: RegExp,
|
|
17
19
|
paramNames?: string[],
|
|
18
|
-
isDetachable?: boolean;
|
|
19
20
|
Component: Function,
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -26,18 +27,10 @@ export class Route extends Component<Props> {
|
|
|
26
27
|
|
|
27
28
|
isDetached = false;
|
|
28
29
|
|
|
29
|
-
domParent: HTMLElement | null = null;
|
|
30
|
-
|
|
31
30
|
domRef = createRef<HTMLDivElement>();
|
|
32
31
|
|
|
33
32
|
component = createRef<IRoute | null>();
|
|
34
33
|
|
|
35
|
-
componentDidMount() {
|
|
36
|
-
const { isDetachable } = this.props;
|
|
37
|
-
this.domParent = this.domRef.current?.parentElement!;
|
|
38
|
-
if (isDetachable) this.detach();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
getParams(): RouteParams {
|
|
42
35
|
const { regexpPath, paramNames } = this.props;
|
|
43
36
|
if (!paramNames || !regexpPath) return {};
|
|
@@ -63,7 +56,6 @@ export class Route extends Component<Props> {
|
|
|
63
56
|
|
|
64
57
|
show() {
|
|
65
58
|
menuService.addEventListener('visibilitychange', this.onMenuVisibilityChange);
|
|
66
|
-
this.showRoute();
|
|
67
59
|
if (!this.wasCreated) {
|
|
68
60
|
this.mountRoute();
|
|
69
61
|
this.component.current?.activate(this.getParams());
|
|
@@ -74,10 +66,7 @@ export class Route extends Component<Props> {
|
|
|
74
66
|
|
|
75
67
|
hide() {
|
|
76
68
|
menuService.removeEventListener('visibilitychange', this.onMenuVisibilityChange);
|
|
77
|
-
|
|
78
|
-
this.component.current?.deactivate();
|
|
79
|
-
this.hideRoute();
|
|
80
|
-
}
|
|
69
|
+
this.deactivate();
|
|
81
70
|
}
|
|
82
71
|
|
|
83
72
|
replace(newRoute: Route) {
|
|
@@ -89,8 +78,9 @@ export class Route extends Component<Props> {
|
|
|
89
78
|
}
|
|
90
79
|
|
|
91
80
|
attach() {
|
|
81
|
+
const { domParent } = this.props;
|
|
92
82
|
if (this.isDetached) {
|
|
93
|
-
attachNode(this.domRef,
|
|
83
|
+
attachNode(this.domRef, domParent!);
|
|
94
84
|
this.isDetached = false;
|
|
95
85
|
}
|
|
96
86
|
}
|
|
@@ -114,14 +104,12 @@ export class Route extends Component<Props> {
|
|
|
114
104
|
}
|
|
115
105
|
}
|
|
116
106
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!isDetachable) this.domRef.current!.style.display = 'block';
|
|
107
|
+
showRoute() {
|
|
108
|
+
this.domRef.current!.style.display = 'block';
|
|
120
109
|
}
|
|
121
110
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!isDetachable) this.domRef.current!.style.display = 'none';
|
|
111
|
+
hideRoute() {
|
|
112
|
+
this.domRef.current!.style.display = 'none';
|
|
125
113
|
}
|
|
126
114
|
|
|
127
115
|
private mountRoute() {
|
|
@@ -134,13 +122,8 @@ export class Route extends Component<Props> {
|
|
|
134
122
|
}
|
|
135
123
|
|
|
136
124
|
render() {
|
|
137
|
-
const { isDetachable } = this.props;
|
|
138
125
|
return (
|
|
139
|
-
<div
|
|
140
|
-
className="route"
|
|
141
|
-
style={!isDetachable ? { display: 'none' } : {}}
|
|
142
|
-
ref={this.domRef}
|
|
143
|
-
/>
|
|
126
|
+
<div className="route" ref={this.domRef} />
|
|
144
127
|
);
|
|
145
128
|
}
|
|
146
129
|
}
|
|
@@ -28,6 +28,8 @@ const filterNulls = (allChildren: (JSX.Element | null)[]) => (
|
|
|
28
28
|
export class Router extends Component<Props> {
|
|
29
29
|
paths: { [key: string]: RoutePath } = {};
|
|
30
30
|
|
|
31
|
+
routerDomRef = createRef<HTMLDivElement>();
|
|
32
|
+
|
|
31
33
|
static defaultProps = {
|
|
32
34
|
defaultPath: '/',
|
|
33
35
|
detachInactiveRoutes: true,
|
|
@@ -38,12 +40,14 @@ export class Router extends Component<Props> {
|
|
|
38
40
|
constructor(props: Props) {
|
|
39
41
|
super(props);
|
|
40
42
|
routerRef.current = this;
|
|
41
|
-
this.
|
|
43
|
+
const { children } = this.props;
|
|
44
|
+
this.createRefs(children);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
componentDidMount() {
|
|
45
48
|
window.document.addEventListener('keydown', this.onKeyDown, false);
|
|
46
49
|
window.addEventListener('hashchange', this.onHashChange, false);
|
|
50
|
+
this.hideAllRoutes();
|
|
47
51
|
this.goToDefaultPath();
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -91,6 +95,8 @@ export class Router extends Component<Props> {
|
|
|
91
95
|
return activeRoutePath?.ref.current || null;
|
|
92
96
|
}
|
|
93
97
|
|
|
98
|
+
// TODO: refactor to reduce complexity
|
|
99
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
94
100
|
switchRoutes(
|
|
95
101
|
routePathToHide: RoutePath | null,
|
|
96
102
|
routePathToShow: RoutePath | null,
|
|
@@ -104,18 +110,31 @@ export class Router extends Component<Props> {
|
|
|
104
110
|
} else if (routePathToShow) {
|
|
105
111
|
routeToHide!.hide();
|
|
106
112
|
routePathToHide.isVisible = false;
|
|
107
|
-
if (detachInactiveRoutes)
|
|
113
|
+
if (detachInactiveRoutes) {
|
|
114
|
+
routeToHide!.replace(routeToShow!);
|
|
115
|
+
} else {
|
|
116
|
+
routeToHide!.hideRoute();
|
|
117
|
+
routeToShow!.showRoute();
|
|
118
|
+
}
|
|
108
119
|
routeToShow!.show();
|
|
109
120
|
routePathToShow.isVisible = true;
|
|
110
121
|
return;
|
|
111
122
|
} else {
|
|
112
123
|
routeToHide!.hide();
|
|
113
124
|
routePathToHide.isVisible = false;
|
|
114
|
-
if (detachInactiveRoutes)
|
|
125
|
+
if (detachInactiveRoutes) {
|
|
126
|
+
routeToHide!.detach();
|
|
127
|
+
} else {
|
|
128
|
+
routeToHide!.hideRoute();
|
|
129
|
+
}
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
if (routePathToShow) {
|
|
118
|
-
if (detachInactiveRoutes)
|
|
133
|
+
if (detachInactiveRoutes) {
|
|
134
|
+
routeToShow!.attach();
|
|
135
|
+
} else {
|
|
136
|
+
routeToShow!.showRoute();
|
|
137
|
+
}
|
|
119
138
|
routeToShow!.show();
|
|
120
139
|
routePathToShow.isVisible = true;
|
|
121
140
|
}
|
|
@@ -125,11 +144,10 @@ export class Router extends Component<Props> {
|
|
|
125
144
|
this.getActiveRoute()?.focus();
|
|
126
145
|
}
|
|
127
146
|
|
|
128
|
-
createRefs() {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const { path } = child.props;
|
|
147
|
+
createRefs(routes: JSX.Element[]) {
|
|
148
|
+
forEach(routes, (route: JSX.Element) => {
|
|
149
|
+
if (route.type === Route) {
|
|
150
|
+
const { path } = route.props;
|
|
133
151
|
const { regexpPath, paramNames } = pathToRegExp(path);
|
|
134
152
|
this.paths[path] = {
|
|
135
153
|
ref: createRef<Route>(),
|
|
@@ -151,9 +169,28 @@ export class Router extends Component<Props> {
|
|
|
151
169
|
}
|
|
152
170
|
}
|
|
153
171
|
|
|
154
|
-
|
|
155
|
-
const {
|
|
156
|
-
|
|
172
|
+
hideAllRoutes() {
|
|
173
|
+
const { detachInactiveRoutes } = this.props;
|
|
174
|
+
forEach(Object.keys(this.paths), (key: string) => {
|
|
175
|
+
const route = this.paths[key];
|
|
176
|
+
if (!route.isVisible) {
|
|
177
|
+
if (detachInactiveRoutes) {
|
|
178
|
+
route.ref.current!.detach();
|
|
179
|
+
} else {
|
|
180
|
+
route.ref.current!.hideRoute();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
appendRoutes(routes: JSX.Element[]) {
|
|
187
|
+
this.createRefs(routes);
|
|
188
|
+
this.appendMount(this.renderRoutes(routes), this.routerDomRef);
|
|
189
|
+
this.hideAllRoutes();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
renderRoutes(routes: JSX.Element[]) {
|
|
193
|
+
return filterNulls(map(routes, (child: JSX.Element) => {
|
|
157
194
|
if (child.type === Route) {
|
|
158
195
|
const { path, Component: RouteComponent } = child.props;
|
|
159
196
|
const route = this.paths[path];
|
|
@@ -161,14 +198,23 @@ export class Router extends Component<Props> {
|
|
|
161
198
|
<Route
|
|
162
199
|
ref={route.ref}
|
|
163
200
|
path={path}
|
|
201
|
+
domParent={this.routerDomRef}
|
|
164
202
|
regexpPath={route.regexpPath}
|
|
165
203
|
Component={RouteComponent}
|
|
166
204
|
paramNames={route.paramNames}
|
|
167
|
-
isDetachable={detachInactiveRoutes}
|
|
168
205
|
/>
|
|
169
206
|
);
|
|
170
207
|
}
|
|
171
208
|
return null;
|
|
172
209
|
}));
|
|
173
210
|
}
|
|
211
|
+
|
|
212
|
+
render() {
|
|
213
|
+
const { children } = this.props;
|
|
214
|
+
return (
|
|
215
|
+
<div ref={this.routerDomRef} className="router">
|
|
216
|
+
{this.renderRoutes(children)}
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
174
220
|
}
|