@24i/bigscreen-sdk 1.0.8-alpha.2181 → 1.0.8-alpha.2183

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.2181",
3
+ "version": "1.0.8-alpha.2183",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,6 +20,11 @@ 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
+ }
23
28
  if (userAgent.match(/Tizen/)) {
24
29
  info('Tizen');
25
30
  return new DeviceTizen();
@@ -40,11 +45,6 @@ const getDevice = () => {
40
45
  info('KreaTV');
41
46
  return new DeviceKreaTV();
42
47
  }
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');
@@ -137,29 +137,18 @@ export class PlayerUI extends Component<Props>
137
137
  };
138
138
 
139
139
  onKeyForward = () => {
140
- if (this.seeking.isAutomaticallySeekingBackward) {
141
- this.seeking.stopAutomaticSeek();
142
- return true;
143
- }
144
- if (!this.seeking.isAutomaticallySeekingForward) {
145
- this.seeking.startAutomaticSeekForward();
146
- this.disableHiding();
147
- return true;
148
- }
149
- return false;
140
+ if (this.seeking.isAutomaticallySeekingBackward) this.seeking.stopAutomaticSeek();
141
+ this.disableHiding();
142
+ this.seeking.automaticSeekForward();
143
+ return true;
150
144
  };
151
145
 
152
146
  onKeyRewind = () => {
153
- if (this.seeking.isAutomaticallySeekingForward) {
154
- this.seeking.stopAutomaticSeek();
155
- return true;
156
- }
157
- if (!this.seeking.isAutomaticallySeekingBackward) {
158
- this.seeking.startAutomaticSeekBackward();
159
- this.disableHiding();
160
- return true;
161
- }
162
- return false;
147
+ if (this.seeking.isAutomaticallySeekingForward) this.seeking.stopAutomaticSeek();
148
+ this.disableHiding();
149
+ this.seeking.automaticSeekBackward();
150
+ return true;
151
+
163
152
  };
164
153
 
165
154
  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 = 20000;
14
+ const FAST_TIME = 30000;
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
- leftConsecutives = 0;
29
+ leftConsecutiveness = 0;
30
30
 
31
- rightConsecutives = 0;
31
+ rightConsecutiveness = 0;
32
32
 
33
33
  leftConsecutiveTimeout = createTimeout();
34
34
 
@@ -116,13 +116,13 @@ export class Seekbar extends Component<Props> implements IFocusable {
116
116
 
117
117
  onLeft = () => {
118
118
  const { ui } = this.props;
119
- this.leftConsecutives += 1;
119
+ this.leftConsecutiveness += 1;
120
120
  if (ui.seeking.isAutomaticallySeeking()) {
121
121
  ui.seeking.stopAutomaticSeek();
122
122
  }
123
- ui.seeking.seekBackward(this.leftConsecutives >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
123
+ ui.seeking.seekBackward(this.leftConsecutiveness >= FAST_TRESHOLD ? FAST_TIME : SLOW_TIME);
124
124
  this.leftConsecutiveTimeout.set(() => {
125
- this.leftConsecutives = 0;
125
+ this.leftConsecutiveness = 0;
126
126
  }, CONSECUTIVE_TIMEOUT);
127
127
  return true;
128
128
  };
@@ -131,11 +131,11 @@ export class Seekbar extends Component<Props> implements IFocusable {
131
131
  const { ui } = this.props;
132
132
  const { seekTime } = ui.seeking;
133
133
  if (seekTime == null && this.currentTime + SLOW_TIME >= this.duration) return true;
134
- this.rightConsecutives += 1;
134
+ this.rightConsecutiveness += 1;
135
135
  if (ui.seeking.isAutomaticallySeeking()) {
136
136
  ui.seeking.stopAutomaticSeek();
137
137
  }
138
- const isFastSeeking = this.rightConsecutives >= FAST_TRESHOLD;
138
+ const isFastSeeking = this.rightConsecutiveness >= FAST_TRESHOLD;
139
139
  if (
140
140
  (seekTime != null &&
141
141
  (seekTime + SLOW_TIME >= this.duration - SAFE_END_MARGIN
@@ -147,7 +147,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
147
147
  ui.seeking.seekForward(isFastSeeking ? FAST_TIME : SLOW_TIME);
148
148
  }
149
149
  this.rightConsecutiveTimeout.set(() => {
150
- this.rightConsecutives = 0;
150
+ this.rightConsecutiveness = 0;
151
151
  }, CONSECUTIVE_TIMEOUT);
152
152
  return true;
153
153
  };
@@ -1,9 +1,12 @@
1
1
  import { IEvents, EventMapType, EventsManager } from '@24i/bigscreen-sdk/events-manager';
2
- import { createInterval } from '@24i/bigscreen-sdk/utils/timers';
2
+ import { createInterval, createTimeout } from '@24i/bigscreen-sdk/utils/timers';
3
3
  import { PlayerBase } from '@24i/player-base';
4
4
 
5
- const DEFAULT_SEEK_TIME = 20000;
5
+ const DEFAULT_SEEK_TIME = 10000;
6
+ const FAST_SEEK_TIME = 30000;
6
7
  const AUTOMATIC_SEEK_INTERVAL = 300;
8
+ const FAST_THRESHOLD = 5;
9
+ const CONSECUTIVE_TIMEOUT = 500;
7
10
 
8
11
  interface SeekingEventsMap extends EventMapType {
9
12
  'seektimeupdate': (payload: number) => void,
@@ -29,6 +32,14 @@ export class Seeking implements IEvents<SeekingEventsMap> {
29
32
 
30
33
  isAutomaticallySeekingBackward = false;
31
34
 
35
+ ffConsecutiveness = 0;
36
+
37
+ rewConsecutiveness = 0;
38
+
39
+ ffConsecutiveTimeout = createTimeout();
40
+
41
+ rewConsecutiveTimeout = createTimeout();
42
+
32
43
  constructor(player: PlayerBase<any> | null = null) {
33
44
  this.player = player;
34
45
  }
@@ -76,22 +87,44 @@ export class Seeking implements IEvents<SeekingEventsMap> {
76
87
  this.triggerEvent('seektimeupdate', this.seekTime!);
77
88
  }
78
89
 
79
- startAutomaticSeekForward() {
80
- this.stopAutomaticSeek();
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
+ }
81
104
  this.isAutomaticallySeekingForward = true;
105
+ this.ffConsecutiveness += 1;
82
106
  this.seekForward();
83
- this.automaticSeekInterval.set(() => {
84
- this.seekForward();
85
- }, AUTOMATIC_SEEK_INTERVAL);
107
+ this.automaticSeekInterval.set(() => this.seekForward(), AUTOMATIC_SEEK_INTERVAL);
86
108
  }
87
109
 
88
- startAutomaticSeekBackward() {
89
- this.stopAutomaticSeek();
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
+ }
90
124
  this.isAutomaticallySeekingBackward = true;
125
+ this.rewConsecutiveness += 1;
91
126
  this.seekBackward();
92
- this.automaticSeekInterval.set(() => {
93
- this.seekBackward();
94
- }, AUTOMATIC_SEEK_INTERVAL);
127
+ this.automaticSeekInterval.set(() => this.seekBackward(), AUTOMATIC_SEEK_INTERVAL);
95
128
  }
96
129
 
97
130
  stopAutomaticSeek() {
@@ -99,6 +132,8 @@ export class Seeking implements IEvents<SeekingEventsMap> {
99
132
  this.automaticSeekInterval.clear();
100
133
  this.isAutomaticallySeekingForward = false;
101
134
  this.isAutomaticallySeekingBackward = false;
135
+ this.ffConsecutiveness = 0;
136
+ this.rewConsecutiveness = 0;
102
137
  }
103
138
 
104
139
  cancelSeek() {
@@ -13,12 +13,16 @@ 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!,
16
20
  isSeeking: jest.fn(),
17
21
  startSeeking: jest.fn(),
18
22
  seekForward: jest.fn(),
19
23
  seekBackward: jest.fn(),
20
- startAutomaticSeekForward: jest.fn(),
21
- startAutomaticSeekBackward: jest.fn(),
24
+ automaticSeekForward: jest.fn(),
25
+ automaticSeekBackward: jest.fn(),
22
26
  stopAutomaticSeek: jest.fn(),
23
27
  cancelSeek: jest.fn(),
24
28
  confirmSeek: jest.fn(),