@24i/bigscreen-sdk 1.0.8-alpha.2184 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.8-alpha.2184",
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');
@@ -384,7 +384,3 @@ export const GAMEPAD_A = new Key({
384
384
  export const GAMEPAD_B = new Key({
385
385
  id: 'GAMEPAD_B',
386
386
  });
387
-
388
- export const SUBTITLES = new Key({
389
- id: 'SUBTITLES',
390
- });
@@ -38,5 +38,4 @@ export const KEYMAP = {
38
38
  KP_9: 105,
39
39
  CHANNEL_UP: 33,
40
40
  CHANNEL_DOWN: 34,
41
- SUBTITLES: 83,
42
41
  };
@@ -82,6 +82,4 @@ export type KeycodeKeyMap = {
82
82
 
83
83
  GAMEPAD_A: number,
84
84
  GAMEPAD_B: number,
85
-
86
- SUBTITLES: number,
87
85
  };
@@ -9,14 +9,6 @@ export const getKeyMap = () => {
9
9
  VOL_UP: { code: 'KeyU', keyCode: 85 },
10
10
  VOL_DOWN: { code: 'KeyJ', keyCode: 74 },
11
11
  MUTE: { code: 'KeyM', keyCode: 77 },
12
- PLAY: { code: 'KeyO', keyCode: 79 },
13
- PAUSE: { code: 'KeyP', keyCode: 80 },
14
- PLAYPAUSE: { code: 'Space', keyCode: 32 },
15
- FF: { code: 'Period', keyCode: 190 },
16
- REW: { code: 'Comma', keyCode: 188 },
17
- STOP: { code: 'Escape', keyCode: 27 },
18
- SUBTITLES: { code: 'KeyS', keyCode: 83 },
19
- REC: { code: 'KeyI', keyCode: 73 },
20
12
  });
21
13
  return generateKeyCodeKeyMap();
22
14
  };
@@ -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(diff = 1) {
83
- const targetScrollIndex = this.controller.scrollIndex - diff;
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 { FF, REW, switchByKey } from '@24i/bigscreen-sdk/device/keymap';
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,
@@ -23,7 +23,6 @@ type Props = {
23
23
  onClose?: () => void,
24
24
  onHide?: () => void,
25
25
  isPauseAllowed?: () => boolean,
26
- showSubtitlesPicker?: () => void,
27
26
  };
28
27
 
29
28
  export class PlayerUI extends Component<Props>
@@ -85,17 +84,8 @@ export class PlayerUI extends Component<Props>
85
84
  STOP: this.onKeyStop,
86
85
  FF: this.onKeyForward,
87
86
  REW: this.onKeyRewind,
88
- SUBTITLES: this.onKeySubtitles,
89
87
  });
90
- if (processed && !FF.is(event) && !REW.is(event)) stopEvent(event);
91
- };
92
-
93
- onKeySubtitles = () => {
94
- const { showSubtitlesPicker } = this.props;
95
- if (showSubtitlesPicker) {
96
- showSubtitlesPicker();
97
- }
98
- return true;
88
+ if (processed) stopEvent(event);
99
89
  };
100
90
 
101
91
  onKeyPlay = () => {
@@ -147,18 +137,27 @@ export class PlayerUI extends Component<Props>
147
137
  };
148
138
 
149
139
  onKeyForward = () => {
150
- if (this.seeking.isAutomaticallySeekingBackward) this.seeking.stopAutomaticSeek();
151
- this.disableHiding();
152
- this.seeking.automaticSeekForward();
153
- return true;
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;
154
149
  };
155
150
 
156
151
  onKeyRewind = () => {
157
- if (this.seeking.isAutomaticallySeekingForward) this.seeking.stopAutomaticSeek();
158
- this.disableHiding();
159
- this.seeking.automaticSeekBackward();
160
- return true;
161
-
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;
162
161
  };
163
162
 
164
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 = 30000;
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
- leftConsecutiveness = 0;
29
+ leftConsecutives = 0;
30
30
 
31
- rightConsecutiveness = 0;
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.leftConsecutiveness += 1;
117
+ this.leftConsecutives += 1;
120
118
  if (ui.seeking.isAutomaticallySeeking()) {
121
119
  ui.seeking.stopAutomaticSeek();
122
120
  }
123
- ui.seeking.seekBackward(this.leftConsecutiveness >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
121
+ ui.seeking.seekBackward(this.leftConsecutives >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
124
122
  this.leftConsecutiveTimeout.set(() => {
125
- this.leftConsecutiveness = 0;
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.rightConsecutiveness += 1;
132
+ this.rightConsecutives += 1;
135
133
  if (ui.seeking.isAutomaticallySeeking()) {
136
134
  ui.seeking.stopAutomaticSeek();
137
135
  }
138
- const isFastSeeking = this.rightConsecutiveness >= FAST_TRESHOLD;
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.rightConsecutiveness = 0;
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, createTimeout } from '@24i/bigscreen-sdk/utils/timers';
2
+ import { createInterval } from '@24i/bigscreen-sdk/utils/timers';
3
3
  import { PlayerBase } from '@24i/player-base';
4
4
 
5
- const DEFAULT_SEEK_TIME = 10000;
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
- automaticSeekForward() {
91
- if (this.isAutomaticallySeekingForward) {
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(() => this.seekForward(), AUTOMATIC_SEEK_INTERVAL);
83
+ this.automaticSeekInterval.set(() => {
84
+ this.seekForward();
85
+ }, AUTOMATIC_SEEK_INTERVAL);
108
86
  }
109
87
 
110
- automaticSeekBackward() {
111
- if (this.isAutomaticallySeekingBackward) {
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(() => this.seekBackward(), AUTOMATIC_SEEK_INTERVAL);
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
- automaticSeekForward: jest.fn(),
25
- automaticSeekBackward: jest.fn(),
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 = 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
- }
@@ -1,6 +0,0 @@
1
- export {
2
- Options,
3
- ParamOptions,
4
- ServiceDataResponse,
5
- getTime,
6
- } from './24iMediaTimeApi';