@applicaster/quick-brick-player 13.0.0-alpha.8490438700 → 13.0.0-alpha.8532113155
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": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.8532113155",
|
|
4
4
|
"description": "Quick Brick Player",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@applicaster/quick-brick-mobile-transport-controls": "13.0.0-rc.28",
|
|
40
|
-
"@applicaster/quick-brick-tv-transport-controls": "13.0.0-rc.
|
|
41
|
-
"@applicaster/zapp-react-native-tvos-app": "13.0.0-alpha.
|
|
42
|
-
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.
|
|
43
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
40
|
+
"@applicaster/quick-brick-tv-transport-controls": "13.0.0-rc.31",
|
|
41
|
+
"@applicaster/zapp-react-native-tvos-app": "13.0.0-alpha.8532113155",
|
|
42
|
+
"@applicaster/zapp-react-native-ui-components": "13.0.0-alpha.8532113155",
|
|
43
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.8532113155",
|
|
44
44
|
"keymirror": "^0.1.1",
|
|
45
45
|
"query-string": "7.1.3",
|
|
46
46
|
"react-native-web-linear-gradient": "1.1.2",
|
|
@@ -328,8 +328,12 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
|
|
|
328
328
|
onSleepSelect,
|
|
329
329
|
]);
|
|
330
330
|
|
|
331
|
+
// This method does not actually cancel the sleep timer
|
|
332
|
+
// (and should not to avoid race condition),
|
|
333
|
+
// it just performs the cleanup when timer expires
|
|
334
|
+
// TODO: rename it in code above
|
|
331
335
|
const cancelSleepTimer = React.useCallback(() => {
|
|
332
|
-
sleepTimerManager?.
|
|
336
|
+
sleepTimerManager?.onTimerExpired();
|
|
333
337
|
}, [sleepTimerManager]);
|
|
334
338
|
|
|
335
339
|
const onCloseVideoModal = React.useCallback(() => {
|
|
@@ -40,94 +40,77 @@ export class SleepTimerController {
|
|
|
40
40
|
return this.sleepTimerStateSubject.asObservable();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
async
|
|
44
|
-
|
|
43
|
+
private async scheduleSleep(sleepDate): Promise<boolean> {
|
|
44
|
+
log_debug(`Setting sleep interval to ${sleepDate}`);
|
|
45
45
|
|
|
46
|
-
await localStorage.removeItem(SLEEP_PREFERENCE_KEY, NAMESPACE);
|
|
47
|
-
|
|
48
|
-
this.sleepTimerStateSubject.next(new SleepTimerState(SLEEP_TIMER_OFF, 0));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private async startSleepTimer(futureSleepDate: number) {
|
|
52
46
|
try {
|
|
53
|
-
log_debug(`Starting sleep timer at ${futureSleepDate}`);
|
|
54
47
|
this.player.cancelSleepTimer?.();
|
|
55
|
-
this.player.startSleepTimer?.(
|
|
48
|
+
this.player.startSleepTimer?.(sleepDate);
|
|
56
49
|
|
|
57
|
-
return
|
|
50
|
+
return true;
|
|
58
51
|
} catch (e) {
|
|
59
52
|
log_error("Failed to start sleep timer", { error: e.message });
|
|
60
53
|
|
|
61
|
-
return
|
|
54
|
+
return false;
|
|
62
55
|
}
|
|
63
56
|
}
|
|
64
57
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (timerValue === 0) {
|
|
72
|
-
await this.cancelSleepTimer();
|
|
58
|
+
async setSleepTimer(item: SleepTimer) {
|
|
59
|
+
// User has selected Off state
|
|
60
|
+
if (item.value === 0) {
|
|
61
|
+
log_debug("Cancelling sleep timer");
|
|
62
|
+
this.player.cancelSleepTimer?.();
|
|
73
63
|
|
|
74
|
-
return
|
|
64
|
+
return this.onTimerExpired();
|
|
75
65
|
}
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
if (currentFutureSleepDate == null) {
|
|
79
|
-
log_debug(`Starting sleep timer in ${timerValue} minutes`);
|
|
80
|
-
const futureSleepDate = Date.now() + timerValue * 60000;
|
|
67
|
+
log_debug(`Starting sleep timer in ${item.value} minutes`);
|
|
81
68
|
|
|
82
|
-
|
|
83
|
-
}
|
|
69
|
+
const futureSleepDate = Date.now() + item.value * 60000;
|
|
84
70
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
if (await this.scheduleSleep(futureSleepDate)) {
|
|
72
|
+
await localStorage.setItem(
|
|
73
|
+
SLEEP_PREFERENCE_KEY,
|
|
74
|
+
{ ...item, futureSleepDate },
|
|
75
|
+
NAMESPACE
|
|
76
|
+
);
|
|
89
77
|
|
|
90
|
-
|
|
78
|
+
this.sleepTimerStateSubject.next(
|
|
79
|
+
new SleepTimerState(item, futureSleepDate)
|
|
80
|
+
);
|
|
91
81
|
}
|
|
82
|
+
}
|
|
92
83
|
|
|
93
|
-
|
|
84
|
+
async onTimerExpired() {
|
|
85
|
+
await localStorage.removeItem(SLEEP_PREFERENCE_KEY, NAMESPACE);
|
|
94
86
|
|
|
95
|
-
|
|
87
|
+
this.sleepTimerStateSubject.next(new SleepTimerState(SLEEP_TIMER_OFF, 0));
|
|
96
88
|
}
|
|
97
89
|
|
|
98
90
|
async loadSleep() {
|
|
99
91
|
const sleep = await localStorage.getItem(SLEEP_PREFERENCE_KEY, NAMESPACE);
|
|
100
92
|
|
|
101
|
-
if (sleep)
|
|
102
|
-
const { futureSleepDate, ...rest } = sleep;
|
|
93
|
+
if (!sleep) return;
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
sleep.value,
|
|
106
|
-
futureSleepDate
|
|
107
|
-
);
|
|
95
|
+
const { futureSleepDate, ...rest } = sleep;
|
|
108
96
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
97
|
+
if (!futureSleepDate || hasDatePassed(futureSleepDate)) {
|
|
98
|
+
log_debug("Sleep date has already passed");
|
|
99
|
+
await localStorage.removeItem(SLEEP_PREFERENCE_KEY, NAMESPACE);
|
|
112
100
|
|
|
113
|
-
|
|
101
|
+
return;
|
|
114
102
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async setSleepTimer(item: SleepTimer) {
|
|
118
|
-
const futureSleepDate = await this.handleSleep(item.value);
|
|
119
103
|
|
|
120
|
-
await
|
|
121
|
-
|
|
122
|
-
{ ...item, futureSleepDate },
|
|
123
|
-
NAMESPACE
|
|
124
|
-
);
|
|
104
|
+
if (await this.scheduleSleep(futureSleepDate)) {
|
|
105
|
+
log_debug(`Sleep state restored, will go to sleep at ${futureSleepDate}`);
|
|
125
106
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
107
|
+
this.sleepTimerStateSubject.next(
|
|
108
|
+
new SleepTimerState(rest as SleepTimer, futureSleepDate)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
129
111
|
}
|
|
130
112
|
|
|
113
|
+
// Will be called if user closed the player explicitly.
|
|
131
114
|
// TODO: check if it will be called on Android when we need.
|
|
132
115
|
// Probably we will have to handle it on native instead.
|
|
133
116
|
public static async onPlayerDestroy() {
|