@24i/bigscreen-sdk 1.0.18-bs-player.2373 → 1.0.18
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 +7 -7
- 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 +0 -12
- package/packages/driver-androidtv/src/types.ts +0 -40
- 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 +4 -12
- package/packages/player-ui/src/types.ts +2 -2
- package/packages/router/src/Route.tsx +27 -10
- package/packages/router/src/Router.tsx +13 -59
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.18
|
|
3
|
+
"version": "1.0.18",
|
|
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.
|
|
43
|
+
"@24i/player-base": "6.10.0",
|
|
44
|
+
"@24i/smartapps-datalayer": "3.0.7-alpha.998",
|
|
45
45
|
"@sentry/browser": "7.35.0",
|
|
46
46
|
"@sentry/types": "7.35.0",
|
|
47
47
|
"@types/gtag.js": "^0.0.12",
|
|
@@ -55,11 +55,11 @@
|
|
|
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.
|
|
59
|
-
"@babel/preset-env": "^7.
|
|
58
|
+
"@babel/core": "^7.21.0",
|
|
59
|
+
"@babel/preset-env": "^7.20.2",
|
|
60
60
|
"@types/fs-extra": "^11.0.1",
|
|
61
61
|
"@types/inquirer": "^9.0.3",
|
|
62
|
-
"@types/jest": "^29.
|
|
62
|
+
"@types/jest": "^29.2.3",
|
|
63
63
|
"@types/minimist": "^1.2.2",
|
|
64
64
|
"@types/node": "^18.7.18",
|
|
65
65
|
"@types/react": "^18.0.33",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"fs-extra": "^11.1.0",
|
|
71
71
|
"full-icu": "^1.5.0",
|
|
72
72
|
"identity-obj-proxy": "^3.0.0",
|
|
73
|
-
"inquirer": "^9.
|
|
73
|
+
"inquirer": "^9.1.4",
|
|
74
74
|
"jest": "^29.3.1",
|
|
75
75
|
"jest-canvas-mock": "^2.4.0",
|
|
76
76
|
"jest-environment-jsdom": "^29.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/player-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<any>;
|
|
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<any>) {
|
|
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.getMediaInfo() || {};
|
|
71
71
|
if (this.player.live) {
|
|
72
72
|
try {
|
|
73
|
-
const { programEnd = NaN } = this.player.
|
|
73
|
+
const { programEnd = NaN } = this.player.getMetadata();
|
|
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.getMediaInfo() || {};
|
|
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<any>) {
|
|
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<any>) {
|
|
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<any>) {
|
|
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/player-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<any>;
|
|
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 | null = null;
|
|
19
|
+
playerInstance: PlayerBase<any> | 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<any>) {
|
|
38
38
|
this.playerInstance = playerInstance;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
getMediaInfo() {
|
|
42
|
-
return this.playerInstance?.
|
|
42
|
+
return this.playerInstance?.getMediaInfo() || {};
|
|
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/player-base';
|
|
8
8
|
import { hasEMESupport, getListOfSupportedDRM } from './utils/emeSupport';
|
|
9
9
|
import {
|
|
10
10
|
hasEMESupport as hasEMESupport01b,
|
|
@@ -14,17 +14,5 @@ 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) => {},
|
|
29
17
|
},
|
|
30
18
|
};
|
|
@@ -11,46 +11,6 @@ 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;
|
|
54
14
|
}
|
|
55
15
|
|
|
56
16
|
export type DeviceInfo = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerBase } from '@24i/
|
|
1
|
+
import { PlayerBase } from '@24i/player-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<any>,
|
|
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.getMediaInfo();
|
|
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/player-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.getMetadata() || {};
|
|
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/player-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.getMetadata() || {};
|
|
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/player-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<any>,
|
|
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 | null = null;
|
|
47
|
+
player: PlayerBase<any> | 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<any>) {
|
|
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/player-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.getMetadata() || {};
|
|
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/player-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.getMetadata();
|
|
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.getMetadata();
|
|
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/player-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 | null;
|
|
29
|
+
player: PlayerBase<any> | 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 | null = null) {
|
|
43
|
+
constructor(player: PlayerBase<any> | 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<any>) {
|
|
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/player-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<any>,
|
|
9
9
|
className?: string,
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlayerBase, PlayerBaseMock } from '@24i/player-base';
|
|
2
2
|
import { EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
3
3
|
import { IPlayerUIWithSeeking } from './types';
|
|
4
4
|
|
|
@@ -35,16 +35,8 @@ const getSeekingMock = (): jest.Mocked<IPlayerUIWithSeeking['seeking']> => ({
|
|
|
35
35
|
|
|
36
36
|
const PLAYER_MOCK_DURATION = 60000;
|
|
37
37
|
|
|
38
|
-
export const getPlayerMock = (): PlayerBase => {
|
|
39
|
-
const
|
|
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;
|
|
38
|
+
export const getPlayerMock = (): PlayerBase<any> => {
|
|
39
|
+
const playerMock = new PlayerBaseMock();
|
|
48
40
|
jest.spyOn(playerMock, 'duration', 'get').mockReturnValue(PLAYER_MOCK_DURATION);
|
|
49
41
|
|
|
50
42
|
return playerMock;
|
|
@@ -52,7 +44,7 @@ export const getPlayerMock = (): PlayerBase => {
|
|
|
52
44
|
|
|
53
45
|
export const getUiMock = (): { ui: jest.Mocked<IPlayerUIWithSeeking> } => ({
|
|
54
46
|
ui: {
|
|
55
|
-
getPlayer: jest.fn((): PlayerBase => getPlayerMock()),
|
|
47
|
+
getPlayer: jest.fn((): PlayerBase<any> => getPlayerMock()),
|
|
56
48
|
heartbeat: jest.fn(),
|
|
57
49
|
trigger: jest.fn(),
|
|
58
50
|
isPlaying: jest.fn(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerBase } from '@24i/
|
|
1
|
+
import { PlayerBase } from '@24i/player-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<any>,
|
|
25
25
|
disableHiding: () => void,
|
|
26
26
|
enableHiding: () => void,
|
|
27
27
|
disableSeeking: () => void,
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Component,
|
|
4
4
|
createRef,
|
|
5
5
|
detachNode,
|
|
6
|
-
Reference,
|
|
7
6
|
replaceNode,
|
|
8
7
|
} from '@24i/bigscreen-sdk/jsx';
|
|
9
8
|
import { filter, forEach } from '@24i/bigscreen-sdk/perf-utils/array';
|
|
@@ -14,9 +13,9 @@ import { IRoute, RouteParams } from './types';
|
|
|
14
13
|
|
|
15
14
|
type Props = {
|
|
16
15
|
path: string,
|
|
17
|
-
domParent?: Reference<HTMLElement>;
|
|
18
16
|
regexpPath?: RegExp,
|
|
19
17
|
paramNames?: string[],
|
|
18
|
+
isDetachable?: boolean;
|
|
20
19
|
Component: Function,
|
|
21
20
|
};
|
|
22
21
|
|
|
@@ -27,10 +26,18 @@ export class Route extends Component<Props> {
|
|
|
27
26
|
|
|
28
27
|
isDetached = false;
|
|
29
28
|
|
|
29
|
+
domParent: HTMLElement | null = null;
|
|
30
|
+
|
|
30
31
|
domRef = createRef<HTMLDivElement>();
|
|
31
32
|
|
|
32
33
|
component = createRef<IRoute | null>();
|
|
33
34
|
|
|
35
|
+
componentDidMount() {
|
|
36
|
+
const { isDetachable } = this.props;
|
|
37
|
+
this.domParent = this.domRef.current?.parentElement!;
|
|
38
|
+
if (isDetachable) this.detach();
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
getParams(): RouteParams {
|
|
35
42
|
const { regexpPath, paramNames } = this.props;
|
|
36
43
|
if (!paramNames || !regexpPath) return {};
|
|
@@ -56,6 +63,7 @@ export class Route extends Component<Props> {
|
|
|
56
63
|
|
|
57
64
|
show() {
|
|
58
65
|
menuService.addEventListener('visibilitychange', this.onMenuVisibilityChange);
|
|
66
|
+
this.showRoute();
|
|
59
67
|
if (!this.wasCreated) {
|
|
60
68
|
this.mountRoute();
|
|
61
69
|
this.component.current?.activate(this.getParams());
|
|
@@ -66,7 +74,10 @@ export class Route extends Component<Props> {
|
|
|
66
74
|
|
|
67
75
|
hide() {
|
|
68
76
|
menuService.removeEventListener('visibilitychange', this.onMenuVisibilityChange);
|
|
69
|
-
this.
|
|
77
|
+
if (this.wasCreated) {
|
|
78
|
+
this.component.current?.deactivate();
|
|
79
|
+
this.hideRoute();
|
|
80
|
+
}
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
replace(newRoute: Route) {
|
|
@@ -78,9 +89,8 @@ export class Route extends Component<Props> {
|
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
attach() {
|
|
81
|
-
const { domParent } = this.props;
|
|
82
92
|
if (this.isDetached) {
|
|
83
|
-
attachNode(this.domRef, domParent!);
|
|
93
|
+
attachNode(this.domRef, this.domParent!);
|
|
84
94
|
this.isDetached = false;
|
|
85
95
|
}
|
|
86
96
|
}
|
|
@@ -104,12 +114,14 @@ export class Route extends Component<Props> {
|
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
|
|
107
|
-
showRoute() {
|
|
108
|
-
|
|
117
|
+
private showRoute() {
|
|
118
|
+
const { isDetachable } = this.props;
|
|
119
|
+
if (!isDetachable) this.domRef.current!.style.display = 'block';
|
|
109
120
|
}
|
|
110
121
|
|
|
111
|
-
hideRoute() {
|
|
112
|
-
|
|
122
|
+
private hideRoute() {
|
|
123
|
+
const { isDetachable } = this.props;
|
|
124
|
+
if (!isDetachable) this.domRef.current!.style.display = 'none';
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
private mountRoute() {
|
|
@@ -122,8 +134,13 @@ export class Route extends Component<Props> {
|
|
|
122
134
|
}
|
|
123
135
|
|
|
124
136
|
render() {
|
|
137
|
+
const { isDetachable } = this.props;
|
|
125
138
|
return (
|
|
126
|
-
<div
|
|
139
|
+
<div
|
|
140
|
+
className="route"
|
|
141
|
+
style={!isDetachable ? { display: 'none' } : {}}
|
|
142
|
+
ref={this.domRef}
|
|
143
|
+
/>
|
|
127
144
|
);
|
|
128
145
|
}
|
|
129
146
|
}
|
|
@@ -28,8 +28,6 @@ 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
|
-
|
|
33
31
|
static defaultProps = {
|
|
34
32
|
defaultPath: '/',
|
|
35
33
|
detachInactiveRoutes: true,
|
|
@@ -40,14 +38,12 @@ export class Router extends Component<Props> {
|
|
|
40
38
|
constructor(props: Props) {
|
|
41
39
|
super(props);
|
|
42
40
|
routerRef.current = this;
|
|
43
|
-
|
|
44
|
-
this.createRefs(children);
|
|
41
|
+
this.createRefs();
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
componentDidMount() {
|
|
48
45
|
window.document.addEventListener('keydown', this.onKeyDown, false);
|
|
49
46
|
window.addEventListener('hashchange', this.onHashChange, false);
|
|
50
|
-
this.hideAllRoutes();
|
|
51
47
|
this.goToDefaultPath();
|
|
52
48
|
}
|
|
53
49
|
|
|
@@ -95,8 +91,6 @@ export class Router extends Component<Props> {
|
|
|
95
91
|
return activeRoutePath?.ref.current || null;
|
|
96
92
|
}
|
|
97
93
|
|
|
98
|
-
// TODO: refactor to reduce complexity
|
|
99
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
100
94
|
switchRoutes(
|
|
101
95
|
routePathToHide: RoutePath | null,
|
|
102
96
|
routePathToShow: RoutePath | null,
|
|
@@ -110,31 +104,18 @@ export class Router extends Component<Props> {
|
|
|
110
104
|
} else if (routePathToShow) {
|
|
111
105
|
routeToHide!.hide();
|
|
112
106
|
routePathToHide.isVisible = false;
|
|
113
|
-
if (detachInactiveRoutes)
|
|
114
|
-
routeToHide!.replace(routeToShow!);
|
|
115
|
-
} else {
|
|
116
|
-
routeToHide!.hideRoute();
|
|
117
|
-
routeToShow!.showRoute();
|
|
118
|
-
}
|
|
107
|
+
if (detachInactiveRoutes) routeToHide!.replace(routeToShow!);
|
|
119
108
|
routeToShow!.show();
|
|
120
109
|
routePathToShow.isVisible = true;
|
|
121
110
|
return;
|
|
122
111
|
} else {
|
|
123
112
|
routeToHide!.hide();
|
|
124
113
|
routePathToHide.isVisible = false;
|
|
125
|
-
if (detachInactiveRoutes)
|
|
126
|
-
routeToHide!.detach();
|
|
127
|
-
} else {
|
|
128
|
-
routeToHide!.hideRoute();
|
|
129
|
-
}
|
|
114
|
+
if (detachInactiveRoutes) routeToHide!.detach();
|
|
130
115
|
}
|
|
131
116
|
}
|
|
132
117
|
if (routePathToShow) {
|
|
133
|
-
if (detachInactiveRoutes)
|
|
134
|
-
routeToShow!.attach();
|
|
135
|
-
} else {
|
|
136
|
-
routeToShow!.showRoute();
|
|
137
|
-
}
|
|
118
|
+
if (detachInactiveRoutes) routeToShow!.attach();
|
|
138
119
|
routeToShow!.show();
|
|
139
120
|
routePathToShow.isVisible = true;
|
|
140
121
|
}
|
|
@@ -144,10 +125,11 @@ export class Router extends Component<Props> {
|
|
|
144
125
|
this.getActiveRoute()?.focus();
|
|
145
126
|
}
|
|
146
127
|
|
|
147
|
-
createRefs(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
128
|
+
createRefs() {
|
|
129
|
+
const { children } = this.props;
|
|
130
|
+
forEach(children, (child: JSX.Element) => {
|
|
131
|
+
if (child.type === Route) {
|
|
132
|
+
const { path } = child.props;
|
|
151
133
|
const { regexpPath, paramNames } = pathToRegExp(path);
|
|
152
134
|
this.paths[path] = {
|
|
153
135
|
ref: createRef<Route>(),
|
|
@@ -169,28 +151,9 @@ export class Router extends Component<Props> {
|
|
|
169
151
|
}
|
|
170
152
|
}
|
|
171
153
|
|
|
172
|
-
|
|
173
|
-
const { detachInactiveRoutes } = this.props;
|
|
174
|
-
|
|
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) => {
|
|
154
|
+
render() {
|
|
155
|
+
const { children, detachInactiveRoutes } = this.props;
|
|
156
|
+
return filterNulls(map(children, (child: JSX.Element) => {
|
|
194
157
|
if (child.type === Route) {
|
|
195
158
|
const { path, Component: RouteComponent } = child.props;
|
|
196
159
|
const route = this.paths[path];
|
|
@@ -198,23 +161,14 @@ export class Router extends Component<Props> {
|
|
|
198
161
|
<Route
|
|
199
162
|
ref={route.ref}
|
|
200
163
|
path={path}
|
|
201
|
-
domParent={this.routerDomRef}
|
|
202
164
|
regexpPath={route.regexpPath}
|
|
203
165
|
Component={RouteComponent}
|
|
204
166
|
paramNames={route.paramNames}
|
|
167
|
+
isDetachable={detachInactiveRoutes}
|
|
205
168
|
/>
|
|
206
169
|
);
|
|
207
170
|
}
|
|
208
171
|
return null;
|
|
209
172
|
}));
|
|
210
173
|
}
|
|
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
|
-
}
|
|
220
174
|
}
|