@24i/bigscreen-sdk 1.0.8-alpha.2183 → 1.0.8-alpha.2196
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 +1 -2
- package/packages/device/src/resolver/resolver.ts +5 -5
- package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +2 -4
- package/packages/player-ui/src/PlayerUI.tsx +20 -11
- package/packages/player-ui/src/Seekbar.tsx +9 -13
- package/packages/player-ui/src/Seeking.ts +12 -48
- package/packages/player-ui/src/mocks.ts +2 -6
- package/packages/utils/src/textUtils.ts +1 -3
- package/packages/time/src/adapters/24iMediaTimeApi.ts +0 -47
- package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +0 -43
- package/packages/time/src/services/24iMediaTimeApi/index.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.8-alpha.
|
|
3
|
+
"version": "1.0.8-alpha.2196",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -250,7 +250,6 @@
|
|
|
250
250
|
"./storage": "./packages/storage/src/index.ts",
|
|
251
251
|
"./throbber": "./packages/throbber/src/index.ts",
|
|
252
252
|
"./time/adapters/worldTimeApi": "./packages/time/src/adapters/worldTimeApi.ts",
|
|
253
|
-
"./time/adapters/24iMediaTimeApi": "./packages/time/src/adapters/24iMediaTimeApi.ts",
|
|
254
253
|
"./time": "./packages/time/src/index.ts",
|
|
255
254
|
"./toast/styles": "./packages/toast/src/Toast/styles.ts",
|
|
256
255
|
"./toast": "./packages/toast/src/index.ts",
|
|
@@ -20,11 +20,6 @@ const getDevice = () => {
|
|
|
20
20
|
info('HbbTV');
|
|
21
21
|
return new DeviceHbbTV();
|
|
22
22
|
}
|
|
23
|
-
// any because JavaScriptBridge property is defined on Android TV Bridge platform
|
|
24
|
-
if (typeof (window as any).JavaScriptBridge !== 'undefined') {
|
|
25
|
-
info('AndroidTV');
|
|
26
|
-
return new DeviceAndroidTV();
|
|
27
|
-
}
|
|
28
23
|
if (userAgent.match(/Tizen/)) {
|
|
29
24
|
info('Tizen');
|
|
30
25
|
return new DeviceTizen();
|
|
@@ -45,6 +40,11 @@ const getDevice = () => {
|
|
|
45
40
|
info('KreaTV');
|
|
46
41
|
return new DeviceKreaTV();
|
|
47
42
|
}
|
|
43
|
+
// any because JavaScriptBridge property is defined on Android TV Bridge platform
|
|
44
|
+
if (typeof (window as any).JavaScriptBridge !== 'undefined') {
|
|
45
|
+
info('AndroidTV');
|
|
46
|
+
return new DeviceAndroidTV();
|
|
47
|
+
}
|
|
48
48
|
// any because ENTONE property is defined on Entone platform
|
|
49
49
|
if (typeof (window as any).ENTONE !== 'undefined') {
|
|
50
50
|
info('Entone');
|
|
@@ -61,8 +61,6 @@ export class FirstOnlyGrid<T extends Item<U>, U>
|
|
|
61
61
|
const linesDiff = Math.floor(grid.index / itemsInGroup) - oldLine;
|
|
62
62
|
if (linesDiff > 0) {
|
|
63
63
|
this.scrollForward(linesDiff);
|
|
64
|
-
} else if (linesDiff < 0) {
|
|
65
|
-
this.scrollBackward(Math.abs(linesDiff));
|
|
66
64
|
}
|
|
67
65
|
};
|
|
68
66
|
|
|
@@ -79,8 +77,8 @@ export class FirstOnlyGrid<T extends Item<U>, U>
|
|
|
79
77
|
this.controller.scroll(targetScrollIndex);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
scrollBackward(
|
|
83
|
-
const targetScrollIndex = this.controller.scrollIndex -
|
|
80
|
+
scrollBackward() {
|
|
81
|
+
const targetScrollIndex = this.controller.scrollIndex - 1;
|
|
84
82
|
this.controller.scroll(targetScrollIndex);
|
|
85
83
|
}
|
|
86
84
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
|
|
2
2
|
import { PlayerBase } from '@24i/player-base';
|
|
3
|
-
import {
|
|
3
|
+
import { switchByKey } from '@24i/bigscreen-sdk/device/keymap';
|
|
4
4
|
import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
|
|
5
5
|
import {
|
|
6
6
|
IDisplayToggler, getDisplayToggler, DISPLAY_NONE,
|
|
@@ -85,7 +85,7 @@ export class PlayerUI extends Component<Props>
|
|
|
85
85
|
FF: this.onKeyForward,
|
|
86
86
|
REW: this.onKeyRewind,
|
|
87
87
|
});
|
|
88
|
-
if (processed
|
|
88
|
+
if (processed) stopEvent(event);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
onKeyPlay = () => {
|
|
@@ -137,18 +137,27 @@ export class PlayerUI extends Component<Props>
|
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
onKeyForward = () => {
|
|
140
|
-
if (this.seeking.isAutomaticallySeekingBackward)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
if (this.seeking.isAutomaticallySeekingBackward) {
|
|
141
|
+
this.seeking.stopAutomaticSeek();
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (!this.seeking.isAutomaticallySeekingForward) {
|
|
145
|
+
this.seeking.startAutomaticSeekForward();
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
144
149
|
};
|
|
145
150
|
|
|
146
151
|
onKeyRewind = () => {
|
|
147
|
-
if (this.seeking.isAutomaticallySeekingForward)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
if (this.seeking.isAutomaticallySeekingForward) {
|
|
153
|
+
this.seeking.stopAutomaticSeek();
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
if (!this.seeking.isAutomaticallySeekingBackward) {
|
|
157
|
+
this.seeking.startAutomaticSeekBackward();
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
152
161
|
};
|
|
153
162
|
|
|
154
163
|
getPlayer = () => {
|
|
@@ -11,7 +11,7 @@ import { PlayerUICommonProps } from './types';
|
|
|
11
11
|
const CONSECUTIVE_TIMEOUT = 500;
|
|
12
12
|
const FAST_TRESHOLD = 5;
|
|
13
13
|
const SLOW_TIME = 10000;
|
|
14
|
-
const FAST_TIME =
|
|
14
|
+
const FAST_TIME = 20000;
|
|
15
15
|
const SAFE_END_MARGIN = 10000;
|
|
16
16
|
const TO_PERCENT = 100;
|
|
17
17
|
|
|
@@ -26,9 +26,9 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
26
26
|
|
|
27
27
|
seekTime = createRef<PlayerTime>();
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
leftConsecutives = 0;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
rightConsecutives = 0;
|
|
32
32
|
|
|
33
33
|
leftConsecutiveTimeout = createTimeout();
|
|
34
34
|
|
|
@@ -51,7 +51,6 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
51
51
|
document.addEventListener('mouseup', this.onMouseUp);
|
|
52
52
|
document.addEventListener('mousemove', this.onMouseMove);
|
|
53
53
|
ui.seeking.addEventListener('seektimeupdate', this.onSeekTimeUpdate);
|
|
54
|
-
ui.seeking.addEventListener('stopautomaticseek', this.onStopAutomaticSeek);
|
|
55
54
|
ui.getPlayer().addEventListener('timeupdate', this.onTimeUpdate);
|
|
56
55
|
ui.getPlayer().addEventListener('durationchange', this.onDurationUpdate);
|
|
57
56
|
}
|
|
@@ -61,7 +60,6 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
61
60
|
document.removeEventListener('mouseup', this.onMouseUp);
|
|
62
61
|
document.removeEventListener('mousemove', this.onMouseMove);
|
|
63
62
|
ui.seeking.removeEventListener('seektimeupdate', this.onSeekTimeUpdate);
|
|
64
|
-
ui.seeking.removeEventListener('stopautomaticseek', this.onStopAutomaticSeek);
|
|
65
63
|
ui.getPlayer().removeEventListener('timeupdate', this.onTimeUpdate);
|
|
66
64
|
ui.getPlayer().removeEventListener('durationchange', this.onDurationUpdate);
|
|
67
65
|
}
|
|
@@ -116,13 +114,13 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
116
114
|
|
|
117
115
|
onLeft = () => {
|
|
118
116
|
const { ui } = this.props;
|
|
119
|
-
this.
|
|
117
|
+
this.leftConsecutives += 1;
|
|
120
118
|
if (ui.seeking.isAutomaticallySeeking()) {
|
|
121
119
|
ui.seeking.stopAutomaticSeek();
|
|
122
120
|
}
|
|
123
|
-
ui.seeking.seekBackward(this.
|
|
121
|
+
ui.seeking.seekBackward(this.leftConsecutives >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
|
|
124
122
|
this.leftConsecutiveTimeout.set(() => {
|
|
125
|
-
this.
|
|
123
|
+
this.leftConsecutives = 0;
|
|
126
124
|
}, CONSECUTIVE_TIMEOUT);
|
|
127
125
|
return true;
|
|
128
126
|
};
|
|
@@ -131,11 +129,11 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
131
129
|
const { ui } = this.props;
|
|
132
130
|
const { seekTime } = ui.seeking;
|
|
133
131
|
if (seekTime == null && this.currentTime + SLOW_TIME >= this.duration) return true;
|
|
134
|
-
this.
|
|
132
|
+
this.rightConsecutives += 1;
|
|
135
133
|
if (ui.seeking.isAutomaticallySeeking()) {
|
|
136
134
|
ui.seeking.stopAutomaticSeek();
|
|
137
135
|
}
|
|
138
|
-
const isFastSeeking = this.
|
|
136
|
+
const isFastSeeking = this.rightConsecutives >= FAST_TRESHOLD;
|
|
139
137
|
if (
|
|
140
138
|
(seekTime != null &&
|
|
141
139
|
(seekTime + SLOW_TIME >= this.duration - SAFE_END_MARGIN
|
|
@@ -147,7 +145,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
147
145
|
ui.seeking.seekForward(isFastSeeking ? FAST_TIME : SLOW_TIME);
|
|
148
146
|
}
|
|
149
147
|
this.rightConsecutiveTimeout.set(() => {
|
|
150
|
-
this.
|
|
148
|
+
this.rightConsecutives = 0;
|
|
151
149
|
}, CONSECUTIVE_TIMEOUT);
|
|
152
150
|
return true;
|
|
153
151
|
};
|
|
@@ -165,8 +163,6 @@ export class Seekbar extends Component<Props> implements IFocusable {
|
|
|
165
163
|
this.updateSeekBar();
|
|
166
164
|
};
|
|
167
165
|
|
|
168
|
-
onStopAutomaticSeek = () => this.props.ui.enableHiding();
|
|
169
|
-
|
|
170
166
|
onTimeUpdate = ({ currentTime }: ITimeUpdateEvent) => {
|
|
171
167
|
const { ui } = this.props;
|
|
172
168
|
this.currentTime = currentTime;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { IEvents, EventMapType, EventsManager } from '@24i/bigscreen-sdk/events-manager';
|
|
2
|
-
import { createInterval
|
|
2
|
+
import { createInterval } from '@24i/bigscreen-sdk/utils/timers';
|
|
3
3
|
import { PlayerBase } from '@24i/player-base';
|
|
4
4
|
|
|
5
|
-
const DEFAULT_SEEK_TIME =
|
|
6
|
-
const FAST_SEEK_TIME = 30000;
|
|
5
|
+
const DEFAULT_SEEK_TIME = 20000;
|
|
7
6
|
const AUTOMATIC_SEEK_INTERVAL = 300;
|
|
8
|
-
const FAST_THRESHOLD = 5;
|
|
9
|
-
const CONSECUTIVE_TIMEOUT = 500;
|
|
10
7
|
|
|
11
8
|
interface SeekingEventsMap extends EventMapType {
|
|
12
9
|
'seektimeupdate': (payload: number) => void,
|
|
@@ -32,14 +29,6 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
32
29
|
|
|
33
30
|
isAutomaticallySeekingBackward = false;
|
|
34
31
|
|
|
35
|
-
ffConsecutiveness = 0;
|
|
36
|
-
|
|
37
|
-
rewConsecutiveness = 0;
|
|
38
|
-
|
|
39
|
-
ffConsecutiveTimeout = createTimeout();
|
|
40
|
-
|
|
41
|
-
rewConsecutiveTimeout = createTimeout();
|
|
42
|
-
|
|
43
32
|
constructor(player: PlayerBase<any> | null = null) {
|
|
44
33
|
this.player = player;
|
|
45
34
|
}
|
|
@@ -87,53 +76,28 @@ export class Seeking implements IEvents<SeekingEventsMap> {
|
|
|
87
76
|
this.triggerEvent('seektimeupdate', this.seekTime!);
|
|
88
77
|
}
|
|
89
78
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.ffConsecutiveTimeout.set(() => {
|
|
93
|
-
this.ffConsecutiveness = 0;
|
|
94
|
-
}, CONSECUTIVE_TIMEOUT);
|
|
95
|
-
this.ffConsecutiveness += 1;
|
|
96
|
-
if (this.ffConsecutiveness === FAST_THRESHOLD) {
|
|
97
|
-
this.automaticSeekInterval.set(
|
|
98
|
-
() => this.seekForward(FAST_SEEK_TIME),
|
|
99
|
-
AUTOMATIC_SEEK_INTERVAL
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
79
|
+
startAutomaticSeekForward() {
|
|
80
|
+
this.stopAutomaticSeek();
|
|
104
81
|
this.isAutomaticallySeekingForward = true;
|
|
105
|
-
this.ffConsecutiveness += 1;
|
|
106
82
|
this.seekForward();
|
|
107
|
-
this.automaticSeekInterval.set(() =>
|
|
83
|
+
this.automaticSeekInterval.set(() => {
|
|
84
|
+
this.seekForward();
|
|
85
|
+
}, AUTOMATIC_SEEK_INTERVAL);
|
|
108
86
|
}
|
|
109
87
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.rewConsecutiveTimeout.set(() => {
|
|
113
|
-
this.rewConsecutiveness = 0;
|
|
114
|
-
}, CONSECUTIVE_TIMEOUT);
|
|
115
|
-
this.rewConsecutiveness += 1;
|
|
116
|
-
if (this.rewConsecutiveness === FAST_THRESHOLD) {
|
|
117
|
-
this.automaticSeekInterval.set(
|
|
118
|
-
() => this.seekBackward(FAST_SEEK_TIME),
|
|
119
|
-
AUTOMATIC_SEEK_INTERVAL
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
88
|
+
startAutomaticSeekBackward() {
|
|
89
|
+
this.stopAutomaticSeek();
|
|
124
90
|
this.isAutomaticallySeekingBackward = true;
|
|
125
|
-
this.rewConsecutiveness += 1;
|
|
126
91
|
this.seekBackward();
|
|
127
|
-
this.automaticSeekInterval.set(() =>
|
|
92
|
+
this.automaticSeekInterval.set(() => {
|
|
93
|
+
this.seekBackward();
|
|
94
|
+
}, AUTOMATIC_SEEK_INTERVAL);
|
|
128
95
|
}
|
|
129
96
|
|
|
130
97
|
stopAutomaticSeek() {
|
|
131
|
-
if (this.isAutomaticallySeeking()) this.triggerEvent('stopautomaticseek');
|
|
132
98
|
this.automaticSeekInterval.clear();
|
|
133
99
|
this.isAutomaticallySeekingForward = false;
|
|
134
100
|
this.isAutomaticallySeekingBackward = false;
|
|
135
|
-
this.ffConsecutiveness = 0;
|
|
136
|
-
this.rewConsecutiveness = 0;
|
|
137
101
|
}
|
|
138
102
|
|
|
139
103
|
cancelSeek() {
|
|
@@ -13,16 +13,12 @@ const getSeekingMock = (): jest.Mocked<IPlayerUI['seeking']> => ({
|
|
|
13
13
|
isAutomaticallySeeking: jest.fn(),
|
|
14
14
|
isAutomaticallySeekingForward: false,
|
|
15
15
|
isAutomaticallySeekingBackward: false,
|
|
16
|
-
ffConsecutiveness: 0,
|
|
17
|
-
rewConsecutiveness: 0,
|
|
18
|
-
ffConsecutiveTimeout: null!,
|
|
19
|
-
rewConsecutiveTimeout: null!,
|
|
20
16
|
isSeeking: jest.fn(),
|
|
21
17
|
startSeeking: jest.fn(),
|
|
22
18
|
seekForward: jest.fn(),
|
|
23
19
|
seekBackward: jest.fn(),
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
startAutomaticSeekForward: jest.fn(),
|
|
21
|
+
startAutomaticSeekBackward: jest.fn(),
|
|
26
22
|
stopAutomaticSeek: jest.fn(),
|
|
27
23
|
cancelSeek: jest.fn(),
|
|
28
24
|
confirmSeek: jest.fn(),
|
|
@@ -9,7 +9,6 @@ const trimWithEllipsis = (
|
|
|
9
9
|
if (!row.textContent) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
const { visibility } = row.style;
|
|
13
12
|
row.style.visibility = 'hidden';
|
|
14
13
|
const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
|
|
15
14
|
const lineHeight = parseInt(lineHeightString, 10);
|
|
@@ -28,7 +27,6 @@ const trimWithEllipsis = (
|
|
|
28
27
|
} while (numberOfLines <= requestedNumberOfLines
|
|
29
28
|
&& currentPosition < originalTextContent.length);
|
|
30
29
|
row.textContent = stringBuffer.substring(0, stringBuffer.length - 1) + ellipsis;
|
|
31
|
-
|
|
32
30
|
} else {
|
|
33
31
|
let currentPosition = originalTextContent.length - 1;
|
|
34
32
|
do {
|
|
@@ -41,7 +39,7 @@ const trimWithEllipsis = (
|
|
|
41
39
|
row.textContent = `${ellipsis}${stringBuffer.substring(1)}`;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
row.style.visibility =
|
|
42
|
+
row.style.visibility = '';
|
|
45
43
|
};
|
|
46
44
|
|
|
47
45
|
export const trimWithLeadingEllipsis = (
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { HOUR_IN_MS, MINUTE_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
2
|
-
import * as TwentyFourIMediaTimeApi from '../services/24iMediaTimeApi';
|
|
3
|
-
|
|
4
|
-
type ParamOptions = TwentyFourIMediaTimeApi.ParamOptions;
|
|
5
|
-
|
|
6
|
-
const defaultOptions: ParamOptions = {
|
|
7
|
-
timeoutInMs: 30000,
|
|
8
|
-
retryConfig: {
|
|
9
|
-
retry: 2,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Returns a tring in ISO format followed by +/-hh:mm suffix for timezone offset.
|
|
15
|
-
* @param resp Time api response.
|
|
16
|
-
* @returns ISO string with timezone data.
|
|
17
|
-
*/
|
|
18
|
-
const getIsoDateString = (resp: TwentyFourIMediaTimeApi.ServiceDataResponse): string => {
|
|
19
|
-
let datetime = new Date(resp.timestamp + resp.timezone_offset).toISOString();
|
|
20
|
-
const offset = resp.timezone_offset / HOUR_IN_MS;
|
|
21
|
-
if (offset) {
|
|
22
|
-
const sign = offset > 0 ? '+' : '-';
|
|
23
|
-
const hours = Math.abs(offset);
|
|
24
|
-
const minutes = Math.floor((resp.timezone_offset % HOUR_IN_MS) / MINUTE_IN_MS);
|
|
25
|
-
// eslint-disable-next-line no-magic-numbers
|
|
26
|
-
const timeString = sign + `0${hours}`.slice(-2) + ':' + `0${minutes}`.slice(-2);
|
|
27
|
-
datetime = datetime.replace('Z', timeString);
|
|
28
|
-
}
|
|
29
|
-
return datetime;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Wrapper over "TwentyFourIMediaTimeApi.getTime" method requesting the current time
|
|
34
|
-
* from timekeeping server. Transforms the result to ISO string with timezone offset data
|
|
35
|
-
* included.
|
|
36
|
-
*
|
|
37
|
-
* @param options Options object
|
|
38
|
-
*/
|
|
39
|
-
export const getTime = async (options: ParamOptions = {}) => {
|
|
40
|
-
const opts = { ...defaultOptions, ...options };
|
|
41
|
-
const resp = await TwentyFourIMediaTimeApi.getTime(opts);
|
|
42
|
-
|
|
43
|
-
if ('timestamp' in resp && 'timezone_offset' in resp && 'in_dst' in resp) {
|
|
44
|
-
return { datetime: getIsoDateString(resp) };
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package "24iMediaTimeApi" provides a single function to obtain the current time
|
|
3
|
-
* adjusted by local timezone and daylight savings time for use in time package,
|
|
4
|
-
* from 24i time API at https://time.24imedia.tv/
|
|
5
|
-
*/
|
|
6
|
-
import {
|
|
7
|
-
xhrSendRetry, type RetryConfig, type XhrResponse,
|
|
8
|
-
} from '@24i/bigscreen-sdk/utils/xhr';
|
|
9
|
-
|
|
10
|
-
const API_URL = 'https://time.24imedia.tv/';
|
|
11
|
-
|
|
12
|
-
export type Options = {
|
|
13
|
-
/** The request timeout in milliseconds. The value 0 for no timeout */
|
|
14
|
-
timeoutInMs: number,
|
|
15
|
-
/** Retry configuration */
|
|
16
|
-
retryConfig: RetryConfig,
|
|
17
|
-
};
|
|
18
|
-
export type ParamOptions = Partial<Options>;
|
|
19
|
-
|
|
20
|
-
export type ServiceDataResponse = {
|
|
21
|
-
/** Is dailight savings time */
|
|
22
|
-
in_dst: boolean,
|
|
23
|
-
/** Current time in GMT, in milliseconds */
|
|
24
|
-
timestamp: number,
|
|
25
|
-
/** Timezeone offset in milliseconds */
|
|
26
|
-
timezone_offset: number,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Request the current time based on public IP of request.
|
|
31
|
-
*
|
|
32
|
-
* @param options Options object
|
|
33
|
-
*/
|
|
34
|
-
export async function getTime(options?: ParamOptions): Promise<ServiceDataResponse> {
|
|
35
|
-
try {
|
|
36
|
-
const resp = (await xhrSendRetry(API_URL, options)) as XhrResponse;
|
|
37
|
-
const data: any = resp.dataJson || {};
|
|
38
|
-
return data as ServiceDataResponse;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
console.error('[24iMediaTimeApi] Failed to get time', e);
|
|
41
|
-
throw e;
|
|
42
|
-
}
|
|
43
|
-
}
|