@applicaster/zapp-react-native-utils 13.0.0-alpha.2635505531 → 13.0.0-alpha.3244448100
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/appUtils/keyCodes/keysByPlatform.js +4 -3
- package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
- package/appUtils/playerManager/index.ts +6 -2
- package/appUtils/playerManager/player.ts +12 -8
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -15
- package/package.json +2 -2
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +28 -3
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +42 -91
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +205 -97
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +35 -55
- package/reactHooks/player/const.ts +1 -5
- package/reactHooks/player/index.ts +0 -6
- package/appUtils/playerManager/DelayedSeekPlayerWrapper.tsx +0 -180
- package/reactHooks/player/__tests__/useAutoSeek.test.tsx +0 -123
- package/reactHooks/player/__tests__/useTapSeek.test.ts +0 -94
- package/reactHooks/player/useAutoSeek.tsx +0 -106
- package/reactHooks/player/useSeek.tsx +0 -17
- package/reactHooks/player/useTapSeek.tsx +0 -85
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { BehaviorSubject } from "rxjs";
|
|
2
2
|
import { TapSeekController } from "./TapSeekController";
|
|
3
3
|
import { LongPressSeekController } from "./LongPressSeekController";
|
|
4
|
-
import { playerManager } from "../../../appUtils";
|
|
5
4
|
import { SEEK_TYPE } from "../const";
|
|
6
5
|
import { createLogger } from "../../../logger";
|
|
6
|
+
import { Player } from "../../../appUtils/playerManager/player";
|
|
7
|
+
import { SeekKeyHandlerListener } from "../../../appUtils/keyInputHandler/KeyInputHandler";
|
|
8
|
+
import {
|
|
9
|
+
ISeekController,
|
|
10
|
+
ISeekControllerDelegate,
|
|
11
|
+
SeekIncrementalBaseStrategy,
|
|
12
|
+
} from "./ISeekController";
|
|
7
13
|
|
|
8
14
|
export const { log_warning, log_debug, log_info, log_error, log_verbose } =
|
|
9
15
|
createLogger({
|
|
@@ -11,142 +17,244 @@ export const { log_warning, log_debug, log_info, log_error, log_verbose } =
|
|
|
11
17
|
subsystem: "TVSeekController",
|
|
12
18
|
});
|
|
13
19
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
TVSeekController.instance = new TVSeekController();
|
|
19
|
-
}
|
|
20
|
+
export enum SEEK_STRATEGY {
|
|
21
|
+
TAP_SEEK = "TAP_SEEK",
|
|
22
|
+
AUTO_SEEK = "AUTO_SEEK",
|
|
23
|
+
}
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
const CONFIG_TAP_SEEK = {
|
|
26
|
+
CLICKS_BEFORE_PAUSE: 0,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const CONFIG_LONG_PRESS = {
|
|
30
|
+
TIMER_INTERVAL_MS: 200,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const LONG_PRESS_THRESHOLD = 500;
|
|
34
|
+
const SEEK_END_TIMEOUT_DURATION = 700;
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
export class TVSeekController
|
|
37
|
+
implements SeekKeyHandlerListener, ISeekControllerDelegate
|
|
38
|
+
{
|
|
39
|
+
public delayedSeekPosition: number | null = null;
|
|
40
|
+
private readonly playerController: Player;
|
|
27
41
|
private delayedSeekProgressSubject = new BehaviorSubject<number | null>(null);
|
|
42
|
+
isPlayerInitiallyPaused: null | boolean = null;
|
|
43
|
+
currentSeekType: SEEK_TYPE | null = null;
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
private tapSeekController: TapSeekController;
|
|
31
|
-
private longPressSeekController: LongPressSeekController;
|
|
45
|
+
private currentSeekController: ISeekController;
|
|
46
|
+
private readonly tapSeekController: TapSeekController;
|
|
47
|
+
private readonly longPressSeekController: LongPressSeekController;
|
|
48
|
+
private longPressThresholdTimeout: any | null = null;
|
|
49
|
+
private seekEndTimeout: any | null = null;
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
LONG_PRESS_THRESHOLD: 500,
|
|
36
|
-
TIMER_INTERVAL_MS: 300,
|
|
37
|
-
SKIP_INCREMENT_STEP: 5,
|
|
38
|
-
MAX_SKIP_PER_TICK: 300,
|
|
39
|
-
INITIAL_SKIP_AMOUNT: 10,
|
|
40
|
-
};
|
|
51
|
+
constructor(playerController: Player) {
|
|
52
|
+
this.playerController = playerController;
|
|
41
53
|
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
this.tapSeekController = new TapSeekController(
|
|
55
|
+
this,
|
|
56
|
+
new SeekIncrementalBaseStrategy(),
|
|
57
|
+
CONFIG_TAP_SEEK
|
|
58
|
+
);
|
|
44
59
|
|
|
45
60
|
this.longPressSeekController = new LongPressSeekController(
|
|
46
61
|
this,
|
|
47
|
-
|
|
62
|
+
new SeekIncrementalBaseStrategy(),
|
|
63
|
+
CONFIG_LONG_PRESS
|
|
48
64
|
);
|
|
65
|
+
|
|
66
|
+
this.currentSeekController = this.tapSeekController;
|
|
49
67
|
}
|
|
50
68
|
|
|
51
|
-
getDelayedSeekProgressObservable() {
|
|
69
|
+
getDelayedSeekProgressObservable = () => {
|
|
52
70
|
return this.delayedSeekProgressSubject;
|
|
53
|
-
}
|
|
71
|
+
};
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.tapSeekController
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.longPressSeekController
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
setStrategy = (seekStrategy: SEEK_STRATEGY) => {
|
|
74
|
+
switch (seekStrategy) {
|
|
75
|
+
case SEEK_STRATEGY.TAP_SEEK:
|
|
76
|
+
this.currentSeekController = this.tapSeekController;
|
|
77
|
+
log_debug("TVSeekController: setStrategy - TAP_SEEK");
|
|
78
|
+
|
|
79
|
+
break;
|
|
80
|
+
case SEEK_STRATEGY.AUTO_SEEK:
|
|
81
|
+
this.currentSeekController = this.longPressSeekController;
|
|
82
|
+
log_debug("TVSeekController: setStrategy - AUTO_SEEK");
|
|
83
|
+
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
handleStartSeek = (seekType: SEEK_TYPE) => {
|
|
90
|
+
this.currentSeekType = seekType;
|
|
91
|
+
|
|
92
|
+
if (this.isPlayerInitiallyPaused === null) {
|
|
93
|
+
this.isPlayerInitiallyPaused = this.playerController.isPaused();
|
|
94
|
+
}
|
|
74
95
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
this.clearLongPressThresholdTimeout();
|
|
97
|
+
this.clearSeekCompleteTimeout();
|
|
98
|
+
this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
|
|
99
|
+
this.currentSeekController.onStartSeek(seekType);
|
|
78
100
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
101
|
+
this.longPressThresholdTimeout = setTimeout(() => {
|
|
102
|
+
this.setStrategy(SEEK_STRATEGY.AUTO_SEEK);
|
|
103
|
+
this.currentSeekController.onStartSeek(seekType);
|
|
104
|
+
}, LONG_PRESS_THRESHOLD);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
onForwardPress = (): boolean => {
|
|
108
|
+
this.handleStartSeek(SEEK_TYPE.FORWARD);
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
onRewindPress = (): boolean => {
|
|
114
|
+
this.handleStartSeek(SEEK_TYPE.REWIND);
|
|
83
115
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
onSeekEnd = () => {
|
|
120
|
+
this.currentSeekController.onSeekEnd();
|
|
121
|
+
this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
onRewindPressOut = () => {
|
|
125
|
+
this.onSeekEnd();
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
onForwardPressOut = () => {
|
|
129
|
+
this.onSeekEnd();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
public onVideoProgress = (position: number) => {
|
|
133
|
+
if (this.delayedSeekPosition !== null) {
|
|
134
|
+
return;
|
|
87
135
|
}
|
|
88
136
|
|
|
89
|
-
|
|
90
|
-
|
|
137
|
+
// TODO: If 1 second after seek, send
|
|
138
|
+
|
|
139
|
+
this.delayedSeekProgressSubject.next(position);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
handleDelayedSeek = (offset: number = 0) => {
|
|
143
|
+
this.handlePlayerPause();
|
|
144
|
+
|
|
145
|
+
const currentPos =
|
|
146
|
+
this.delayedSeekPosition === null
|
|
147
|
+
? this.playerController.getPosition()
|
|
148
|
+
: this.delayedSeekPosition;
|
|
149
|
+
|
|
91
150
|
let targetPos = currentPos;
|
|
92
151
|
|
|
93
|
-
if (
|
|
94
|
-
targetPos = Math.min(
|
|
152
|
+
if (this.currentSeekType === SEEK_TYPE.FORWARD) {
|
|
153
|
+
targetPos = Math.min(
|
|
154
|
+
currentPos + offset,
|
|
155
|
+
this.playerController.getSeekableDuration()
|
|
156
|
+
);
|
|
157
|
+
} else if (this.currentSeekType === SEEK_TYPE.REWIND) {
|
|
158
|
+
targetPos = Math.max(0, currentPos - offset);
|
|
95
159
|
} else {
|
|
96
|
-
|
|
160
|
+
log_warning(
|
|
161
|
+
`TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
|
|
162
|
+
);
|
|
97
163
|
}
|
|
98
164
|
|
|
99
|
-
this.delayedSeekOffset = newOffset;
|
|
100
|
-
|
|
101
165
|
log_debug(
|
|
102
|
-
`TVSeekController: handleDelayedSeek - targetPos: ${targetPos},
|
|
166
|
+
`TVSeekController: handleDelayedSeek - targetPos: ${targetPos}, skipTime: ${offset}`
|
|
103
167
|
);
|
|
104
168
|
|
|
169
|
+
const prevValue = this.delayedSeekProgressSubject.getValue();
|
|
170
|
+
|
|
171
|
+
if (prevValue !== null) {
|
|
172
|
+
const delta = Math.abs(prevValue - targetPos);
|
|
173
|
+
|
|
174
|
+
if (delta < 1) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this.delayedSeekPosition = targetPos;
|
|
105
180
|
this.delayedSeekProgressSubject.next(targetPos);
|
|
106
|
-
}
|
|
181
|
+
};
|
|
107
182
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
183
|
+
handleSeekTo = (newPosition: number) => {
|
|
184
|
+
this.playerController.seekTo(newPosition);
|
|
185
|
+
|
|
186
|
+
if (!this.isPlayerInitiallyPaused) {
|
|
187
|
+
this.playerController.play();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
114
190
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!player) return;
|
|
191
|
+
handleSeek = (offset: number) => {
|
|
192
|
+
this.playerController[this.currentSeekType](offset);
|
|
118
193
|
|
|
119
|
-
if (
|
|
120
|
-
|
|
194
|
+
if (!this.isPlayerInitiallyPaused) {
|
|
195
|
+
this.playerController.play();
|
|
121
196
|
}
|
|
122
|
-
}
|
|
197
|
+
};
|
|
123
198
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
199
|
+
handleSeekComplete = () => {
|
|
200
|
+
this.clearSeekCompleteTimeout();
|
|
201
|
+
|
|
202
|
+
this.seekEndTimeout = setTimeout(() => {
|
|
203
|
+
if (this.delayedSeekPosition !== null) {
|
|
204
|
+
this.handleSeekTo(this.delayedSeekPosition);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
log_debug(
|
|
208
|
+
`handleSeekComplete: Seek finished, type: ${this.currentSeekController.title}, seekPosition: ${this.delayedSeekPosition}. Reset all states and seek position.`
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
this.resetAll();
|
|
212
|
+
}, SEEK_END_TIMEOUT_DURATION);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
isAutoSeeking = (): boolean => {
|
|
216
|
+
return this.longPressSeekController.isLongPressActive;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
handlePlayerPause = () => {
|
|
220
|
+
if (this.playerController.isPaused()) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
this.playerController.pause();
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
clearSeekCompleteTimeout = () => {
|
|
228
|
+
if (this.seekEndTimeout === null) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
clearTimeout(this.seekEndTimeout);
|
|
233
|
+
this.seekEndTimeout = null;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
clearLongPressThresholdTimeout = () => {
|
|
237
|
+
if (this.longPressThresholdTimeout === null) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
clearTimeout(this.longPressThresholdTimeout);
|
|
242
|
+
this.longPressThresholdTimeout = null;
|
|
243
|
+
};
|
|
129
244
|
|
|
130
|
-
/**
|
|
131
|
-
* Reset *all* relevant state and strategy controllers
|
|
132
|
-
*/
|
|
133
245
|
resetAll() {
|
|
134
246
|
log_debug("TVSeekController: Reset all states");
|
|
135
247
|
this.currentSeekType = null;
|
|
136
|
-
this.delayedSeekOffset = null;
|
|
137
|
-
this.delayedSeekProgressSubject.next(null);
|
|
138
248
|
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
}
|
|
249
|
+
this.delayedSeekPosition = null;
|
|
250
|
+
this.isPlayerInitiallyPaused = null;
|
|
142
251
|
|
|
143
|
-
|
|
144
|
-
|
|
252
|
+
this.clearSeekCompleteTimeout();
|
|
253
|
+
this.clearLongPressThresholdTimeout();
|
|
145
254
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
255
|
+
this.tapSeekController.reset();
|
|
256
|
+
this.longPressSeekController.reset();
|
|
149
257
|
|
|
150
|
-
|
|
258
|
+
this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
|
|
151
259
|
}
|
|
152
260
|
}
|
|
@@ -1,73 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
ISeekController,
|
|
3
|
+
ISeekControllerDelegate,
|
|
4
|
+
SeekIncrementalBaseStrategy,
|
|
5
|
+
} from "./ISeekController";
|
|
6
|
+
import { SEEK_TYPE } from "../const";
|
|
7
|
+
import { log_debug } from "./TVSeekController";
|
|
8
|
+
|
|
9
|
+
interface TapPressConfig {
|
|
10
|
+
CLICKS_BEFORE_PAUSE: number;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
export class TapSeekController implements ISeekController {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onPressStart(seekType: SEEK_TYPE) {
|
|
16
|
-
log_debug(`TapSeekController: start tap seek type: ${seekType}.`);
|
|
14
|
+
readonly title = "TapSeek";
|
|
15
|
+
constructor(
|
|
16
|
+
private seekControllerDelegate: ISeekControllerDelegate,
|
|
17
|
+
private seekIncrementalStrategy: SeekIncrementalBaseStrategy,
|
|
18
|
+
private config: TapPressConfig
|
|
19
|
+
) {}
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
onStartSeek = (seekType: SEEK_TYPE) => {
|
|
22
|
+
log_debug(`${this.title}: start tap seek type: ${seekType}.`);
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
this.parent.currentSeekType = seekType;
|
|
25
|
-
|
|
26
|
-
if (this.tapSequenceTimeout) {
|
|
27
|
-
clearTimeout(this.tapSequenceTimeout);
|
|
28
|
-
this.tapSequenceTimeout = null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this.tapSequenceTimeout = setTimeout(() => {
|
|
32
|
-
if (this.parent.delayedSeekOffset !== null) {
|
|
33
|
-
this.parent.seekPlayer(this.parent.delayedSeekOffset);
|
|
34
|
-
}
|
|
24
|
+
const skipTime = this.seekIncrementalStrategy.getSkipTime();
|
|
25
|
+
const seekMultiplier = this.seekIncrementalStrategy.getSkipMultiplier();
|
|
35
26
|
|
|
27
|
+
if (seekMultiplier > this.config.CLICKS_BEFORE_PAUSE) {
|
|
36
28
|
log_debug(
|
|
37
|
-
|
|
29
|
+
`${this.title}: handle delayed seek type:${seekType} - skipTime: ${skipTime}, seekMultiplier: ${seekMultiplier}.`
|
|
38
30
|
);
|
|
39
31
|
|
|
40
|
-
this.
|
|
41
|
-
}, this.ON_PRESS_RESET_DURATION);
|
|
42
|
-
|
|
43
|
-
const clicksBeforePause = 3;
|
|
44
|
-
const skipTime = getSkipTime(this.seekMultiplier);
|
|
45
|
-
|
|
46
|
-
if (this.seekMultiplier > clicksBeforePause) {
|
|
47
|
-
log_debug(
|
|
48
|
-
`TapSeekController: handle delayed seek type:${seekType} - skipTime: ${skipTime}.`
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
this.parent.handleDelayedSeek(seekType, skipTime);
|
|
32
|
+
this.seekControllerDelegate.handleDelayedSeek(skipTime);
|
|
52
33
|
} else {
|
|
53
34
|
log_debug(
|
|
54
|
-
|
|
35
|
+
`${this.title}: handle seek type:${seekType} - skipTime: ${skipTime}.`
|
|
55
36
|
);
|
|
56
37
|
|
|
57
|
-
this.
|
|
38
|
+
this.seekControllerDelegate.handleSeek(skipTime);
|
|
58
39
|
}
|
|
59
40
|
|
|
60
|
-
this.
|
|
61
|
-
}
|
|
41
|
+
this.seekIncrementalStrategy.increment();
|
|
42
|
+
};
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
onSeekEnd = () => {
|
|
45
|
+
this.seekControllerDelegate.handleSeekComplete();
|
|
46
|
+
};
|
|
65
47
|
|
|
66
|
-
|
|
48
|
+
reset = () => {
|
|
49
|
+
log_debug("{this.title}: Reset states");
|
|
67
50
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.tapSequenceTimeout = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
51
|
+
this.seekIncrementalStrategy.reset();
|
|
52
|
+
};
|
|
73
53
|
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { Player } from "./player";
|
|
2
|
-
import { BehaviorSubject } from "rxjs";
|
|
3
|
-
|
|
4
|
-
export class DelayedSeekPlayerWrapper extends Player {
|
|
5
|
-
private wrappedPlayer: Player;
|
|
6
|
-
private delayedSeekPosition: number;
|
|
7
|
-
private wasPlaying: boolean;
|
|
8
|
-
|
|
9
|
-
constructor(props, player: Player) {
|
|
10
|
-
super(props);
|
|
11
|
-
this.wrappedPlayer = player;
|
|
12
|
-
this.delayedSeekPosition = null;
|
|
13
|
-
|
|
14
|
-
this.wrappedPlayer.addListener({
|
|
15
|
-
id: "Master-Wrapper-Listener",
|
|
16
|
-
listener: this,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
this.onPlayerSeekComplete = this.onPlayerSeekComplete.bind(this);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
getOverlayObservable = () => {
|
|
23
|
-
return this.wrappedPlayer.getOverlayObservable();
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
getEntryObservable = (): BehaviorSubject<ZappEntry | null> => {
|
|
27
|
-
return this.wrappedPlayer.getEntryObservable();
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
getEntry = (): ZappEntry | null => this.wrappedPlayer.getEntry();
|
|
31
|
-
|
|
32
|
-
getListener = (): QuickBrickPlayer.SharedPlayerCallBacks => {
|
|
33
|
-
return this.wrappedPlayer.getListener();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
togglePlayPause = () => {
|
|
37
|
-
this.wrappedPlayer.togglePlayPause();
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
selectTrack = (_track) => this.wrappedPlayer.selectTrack(_track);
|
|
41
|
-
|
|
42
|
-
// Implement all default methods by delegating them to wrapped player
|
|
43
|
-
public seekTo = (position: number) => {
|
|
44
|
-
this.wrappedPlayer.seekTo(position);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
public isPlaying = () => {
|
|
48
|
-
return this.wrappedPlayer.isPlaying();
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
public isPaused = () => {
|
|
52
|
-
return this.wrappedPlayer.isPaused();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
public play = () => {
|
|
56
|
-
this.wrappedPlayer.play();
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
public pause = () => {
|
|
60
|
-
this.wrappedPlayer.pause();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
getState = () => {
|
|
64
|
-
const currentState = this.wrappedPlayer.getState();
|
|
65
|
-
|
|
66
|
-
if (this.delayedSeekPosition === null) {
|
|
67
|
-
return currentState;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...currentState,
|
|
72
|
-
contentPosition: this.delayedSeekPosition,
|
|
73
|
-
isPaused: false,
|
|
74
|
-
seekPosition: this.delayedSeekPosition,
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
forward = (deltaTime: number) => {
|
|
79
|
-
if (this.delayedSeekPosition !== null) {
|
|
80
|
-
this.delayedSeekPosition += deltaTime;
|
|
81
|
-
this.playerState.seekPosition = this.delayedSeekPosition;
|
|
82
|
-
|
|
83
|
-
this.onVideoProgress({
|
|
84
|
-
currentTime: this.playerState.seekPosition,
|
|
85
|
-
duration: this.getDuration(),
|
|
86
|
-
seekableDuration: this.playerState.seekableDuration,
|
|
87
|
-
isLive: this.playerState.isLive,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// this.scheduleResumePlayback(DELAYED_SEEK_DELAY, this.delayedSeekPosition);
|
|
91
|
-
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (this.playerState.seekPosition == null) {
|
|
96
|
-
this.playerState.seekPosition = this.playerState.contentPosition;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.playerState.seekPosition += deltaTime;
|
|
100
|
-
|
|
101
|
-
this.wrappedPlayer.forward(deltaTime);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
rewind = (deltaTime: number) => {
|
|
105
|
-
if (this.delayedSeekPosition !== null) {
|
|
106
|
-
this.delayedSeekPosition -= deltaTime;
|
|
107
|
-
|
|
108
|
-
if (this.delayedSeekPosition < 0) {
|
|
109
|
-
this.delayedSeekPosition = 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
this.playerState.seekPosition = this.delayedSeekPosition;
|
|
113
|
-
|
|
114
|
-
this.onVideoProgress({
|
|
115
|
-
currentTime: this.playerState.seekPosition,
|
|
116
|
-
duration: this.getDuration(),
|
|
117
|
-
seekableDuration: this.playerState.seekableDuration,
|
|
118
|
-
isLive: this.playerState.isLive,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// this.scheduleResumePlayback(DELAYED_SEEK_DELAY, this.delayedSeekPosition);
|
|
122
|
-
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (this.playerState.seekPosition == null) {
|
|
127
|
-
this.playerState.seekPosition = this.playerState.contentPosition;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
this.playerState.seekPosition -= deltaTime;
|
|
131
|
-
this.wrappedPlayer.rewind(deltaTime);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
public getConfig = () => this.wrappedPlayer.getConfig();
|
|
135
|
-
|
|
136
|
-
// TODO: replace with enum of supported orientations
|
|
137
|
-
isFullScreenSupported(): boolean {
|
|
138
|
-
return this.wrappedPlayer.isFullScreenSupported();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
public supportsNativeControls = (): boolean =>
|
|
142
|
-
this.wrappedPlayer.supportsNativeControls();
|
|
143
|
-
|
|
144
|
-
public supportNativeCast = (): boolean =>
|
|
145
|
-
this.wrappedPlayer.supportNativeCast();
|
|
146
|
-
|
|
147
|
-
public isInDelayedSeek = () => this.delayedSeekPosition !== null;
|
|
148
|
-
|
|
149
|
-
public enterDelayedSeek() {
|
|
150
|
-
if (this.delayedSeekPosition !== null) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (this.playerState.seekPosition === null) {
|
|
155
|
-
this.playerState.seekPosition = this.playerState.contentPosition;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.delayedSeekPosition = this.playerState.seekPosition;
|
|
159
|
-
|
|
160
|
-
if (!this.isPaused()) {
|
|
161
|
-
this.wasPlaying = true;
|
|
162
|
-
this.wrappedPlayer.pause();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
public exitDelayedSeek() {
|
|
167
|
-
if (this.delayedSeekPosition === null) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
this.wrappedPlayer.seekTo(this.delayedSeekPosition);
|
|
172
|
-
|
|
173
|
-
if (this.wasPlaying) {
|
|
174
|
-
this.wasPlaying = false;
|
|
175
|
-
this.wrappedPlayer.play();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
this.delayedSeekPosition = null;
|
|
179
|
-
}
|
|
180
|
-
}
|