@applicaster/quick-brick-player 17.0.0-alpha.1102403272 → 17.0.0-alpha.1462104515
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": "17.0.0-alpha.
|
|
3
|
+
"version": "17.0.0-alpha.1462104515",
|
|
4
4
|
"description": "Quick Brick Player",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@applicaster/quick-brick-mobile-transport-controls": "
|
|
39
|
-
"@applicaster/quick-brick-tv-transport-controls": "17.0.0-
|
|
40
|
-
"@applicaster/zapp-react-native-tvos-app": "17.0.0-alpha.
|
|
41
|
-
"@applicaster/zapp-react-native-ui-components": "17.0.0-alpha.
|
|
42
|
-
"@applicaster/zapp-react-native-utils": "17.0.0-alpha.
|
|
38
|
+
"@applicaster/quick-brick-mobile-transport-controls": "17.0.0-rc.5",
|
|
39
|
+
"@applicaster/quick-brick-tv-transport-controls": "17.0.0-rc.5",
|
|
40
|
+
"@applicaster/zapp-react-native-tvos-app": "17.0.0-alpha.1462104515",
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components": "17.0.0-alpha.1462104515",
|
|
42
|
+
"@applicaster/zapp-react-native-utils": "17.0.0-alpha.1462104515",
|
|
43
43
|
"query-string": "7.1.3",
|
|
44
44
|
"shaka-player": "4.3.5",
|
|
45
45
|
"typeface-montserrat": "^0.0.54",
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
|
|
6
6
|
import { uiActionsRegistry } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
|
|
7
7
|
import { modalOrchestrator } from "@applicaster/zapp-react-native-utils/modalState/ModalOrchestrator";
|
|
8
|
+
import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState/store";
|
|
8
9
|
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
9
10
|
import { firstValueFrom } from "rxjs";
|
|
10
11
|
|
|
@@ -15,6 +16,13 @@ import {
|
|
|
15
16
|
} from "../playerActions";
|
|
16
17
|
import { SpeedController } from "../SpeedManager";
|
|
17
18
|
import { SleepTimerController } from "../SleepTimerManager";
|
|
19
|
+
import {
|
|
20
|
+
getBottomSheetModalDefaultItemIcon,
|
|
21
|
+
getBottomSheetModalIconProps,
|
|
22
|
+
getBottomSheetModalItemProps,
|
|
23
|
+
getBottomSheetModalLabelProps,
|
|
24
|
+
getBottomSheetModalSelectedItemIcon,
|
|
25
|
+
} from "../../Utils";
|
|
18
26
|
|
|
19
27
|
jest.mock("../../Const/sleepTimerOptions", () => ({
|
|
20
28
|
getSleepTimerOptions: (offLabel: string, sleepTimerValue: number | null) => [
|
|
@@ -40,6 +48,10 @@ jest.mock(
|
|
|
40
48
|
})
|
|
41
49
|
);
|
|
42
50
|
|
|
51
|
+
jest.mock("@applicaster/zapp-react-native-utils/modalState/store", () => ({
|
|
52
|
+
openBottomSheetModal: jest.fn(),
|
|
53
|
+
}));
|
|
54
|
+
|
|
43
55
|
jest.mock(
|
|
44
56
|
"@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage",
|
|
45
57
|
() => ({
|
|
@@ -52,8 +64,6 @@ jest.mock(
|
|
|
52
64
|
);
|
|
53
65
|
|
|
54
66
|
describe("playerActions", () => {
|
|
55
|
-
const openedSheets: ActionType[] = [];
|
|
56
|
-
|
|
57
67
|
let player: {
|
|
58
68
|
getConfig: () => Record<string, string>;
|
|
59
69
|
setPlaybackRate: jest.Mock;
|
|
@@ -66,7 +76,6 @@ describe("playerActions", () => {
|
|
|
66
76
|
let unregisterPlayerActions: () => void;
|
|
67
77
|
|
|
68
78
|
beforeEach(() => {
|
|
69
|
-
openedSheets.length = 0;
|
|
70
79
|
jest.clearAllMocks();
|
|
71
80
|
(localStorage.setItem as jest.Mock).mockResolvedValue(undefined);
|
|
72
81
|
(localStorage.removeItem as jest.Mock).mockResolvedValue(undefined);
|
|
@@ -91,19 +100,12 @@ describe("playerActions", () => {
|
|
|
91
100
|
sleepController = new SleepTimerController(player as any);
|
|
92
101
|
|
|
93
102
|
[
|
|
94
|
-
"openBottomSheet",
|
|
95
103
|
PLAYER_ACTION_TYPES.OPEN_PLAYBACK_SPEED,
|
|
96
104
|
PLAYER_ACTION_TYPES.OPEN_SLEEP_TIMER,
|
|
97
105
|
PLAYER_ACTION_TYPES.SET_PLAYBACK_SPEED,
|
|
98
106
|
PLAYER_ACTION_TYPES.SET_SLEEP_TIMER,
|
|
99
107
|
].forEach((type) => actionExecutor.unregisterAction(type));
|
|
100
108
|
|
|
101
|
-
actionExecutor.registerAction("openBottomSheet", async (action) => {
|
|
102
|
-
openedSheets.push(action);
|
|
103
|
-
|
|
104
|
-
return ActionResult.Success;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
109
|
unregisterPlayerActions = registerPlayerActions({
|
|
108
110
|
speedController,
|
|
109
111
|
sleepController,
|
|
@@ -151,7 +153,7 @@ describe("playerActions", () => {
|
|
|
151
153
|
expect(player.setPlaybackRate).not.toHaveBeenCalled();
|
|
152
154
|
});
|
|
153
155
|
|
|
154
|
-
it("opens playback speed
|
|
156
|
+
it("opens playback speed with audio player theme styles and current speed selected", async () => {
|
|
155
157
|
await speedController.setPlaybackSpeed({
|
|
156
158
|
asset: "speed_1",
|
|
157
159
|
value: 1,
|
|
@@ -162,29 +164,44 @@ describe("playerActions", () => {
|
|
|
162
164
|
});
|
|
163
165
|
|
|
164
166
|
expect(result).toBe(ActionResult.Success);
|
|
167
|
+
expect(openBottomSheetModal).toHaveBeenCalledTimes(1);
|
|
168
|
+
|
|
169
|
+
const { modalBottomSheetContentProps: sheetProps } = (
|
|
170
|
+
openBottomSheetModal as jest.Mock
|
|
171
|
+
).mock.calls[0][0];
|
|
172
|
+
|
|
173
|
+
expect(sheetProps).toMatchObject({
|
|
174
|
+
key: PLAYER_ACTION_IDENTIFIERS.PLAYBACK_SPEED,
|
|
175
|
+
title: "Playback Speed",
|
|
176
|
+
current_selection: expect.objectContaining({ value: 1 }),
|
|
177
|
+
itemProps: getBottomSheetModalItemProps,
|
|
178
|
+
iconProps: getBottomSheetModalIconProps,
|
|
179
|
+
labelProps: getBottomSheetModalLabelProps,
|
|
180
|
+
getSelectedItemIcon: getBottomSheetModalSelectedItemIcon,
|
|
181
|
+
getDefaultItemIcon: getBottomSheetModalDefaultItemIcon,
|
|
182
|
+
iconPlacement: "right",
|
|
183
|
+
});
|
|
165
184
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"1.
|
|
177
|
-
"
|
|
178
|
-
"2x",
|
|
185
|
+
expect(
|
|
186
|
+
sheetProps.items.map((item) => ({
|
|
187
|
+
id: item.id,
|
|
188
|
+
label: item.label,
|
|
189
|
+
value: item.value,
|
|
190
|
+
}))
|
|
191
|
+
).toEqual([
|
|
192
|
+
{ id: "0.8", label: "0.8x", value: 0.8 },
|
|
193
|
+
{ id: "1", label: "1x", value: 1 },
|
|
194
|
+
{ id: "1.2", label: "1.2x", value: 1.2 },
|
|
195
|
+
{ id: "1.5", label: "1.5x", value: 1.5 },
|
|
196
|
+
{ id: "2", label: "2x", value: 2 },
|
|
179
197
|
]);
|
|
180
198
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
).toBe(true);
|
|
199
|
+
await sheetProps.onPress(sheetProps.items[3]);
|
|
200
|
+
|
|
201
|
+
expect(player.setPlaybackRate).toHaveBeenCalledWith(1.5);
|
|
185
202
|
});
|
|
186
203
|
|
|
187
|
-
it("opens sleep timer with
|
|
204
|
+
it("opens sleep timer with audio player theme styles and active timer selected", async () => {
|
|
188
205
|
const timerDate = Date.now() + 15 * 60 * 1000;
|
|
189
206
|
|
|
190
207
|
await sleepController.setSleepTimer(
|
|
@@ -197,17 +214,27 @@ describe("playerActions", () => {
|
|
|
197
214
|
});
|
|
198
215
|
|
|
199
216
|
expect(result).toBe(ActionResult.Success);
|
|
217
|
+
expect(openBottomSheetModal).toHaveBeenCalledTimes(1);
|
|
218
|
+
|
|
219
|
+
const { modalBottomSheetContentProps: sheetProps } = (
|
|
220
|
+
openBottomSheetModal as jest.Mock
|
|
221
|
+
).mock.calls[0][0];
|
|
222
|
+
|
|
223
|
+
expect(sheetProps).toMatchObject({
|
|
224
|
+
key: PLAYER_ACTION_IDENTIFIERS.SLEEP_TIMER,
|
|
225
|
+
title: "Sleep Timer",
|
|
226
|
+
current_selection: expect.objectContaining({ value: 15 }),
|
|
227
|
+
itemProps: getBottomSheetModalItemProps,
|
|
228
|
+
iconProps: getBottomSheetModalIconProps,
|
|
229
|
+
labelProps: getBottomSheetModalLabelProps,
|
|
230
|
+
getSelectedItemIcon: getBottomSheetModalSelectedItemIcon,
|
|
231
|
+
getDefaultItemIcon: getBottomSheetModalDefaultItemIcon,
|
|
232
|
+
iconPlacement: "right",
|
|
233
|
+
});
|
|
200
234
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
expect(sheet.options.replace).toBe(true);
|
|
204
|
-
expect(sheet.options.header.title).toBe("Sleep Timer");
|
|
205
|
-
expect(sheet.options.header.subtitle).toBeUndefined();
|
|
206
|
-
expect(sheet.options.content.behavior.currentSelection).toEqual(["15"]);
|
|
235
|
+
await sheetProps.onPress(sheetProps.items[0]);
|
|
207
236
|
|
|
208
|
-
expect(
|
|
209
|
-
sheet.options.content.items[0].extensions.tap_actions.actions[0].type
|
|
210
|
-
).toBe(PLAYER_ACTION_TYPES.SET_SLEEP_TIMER);
|
|
237
|
+
expect(player.cancelSleepTimer).toHaveBeenCalled();
|
|
211
238
|
});
|
|
212
239
|
|
|
213
240
|
it("setPlaybackSpeed applies the rate and closes the sheet when opened from the picker", async () => {
|
|
@@ -361,9 +388,14 @@ describe("playerActions", () => {
|
|
|
361
388
|
.getAction(PLAYER_ACTION_IDENTIFIERS.SLEEP_TIMER)
|
|
362
389
|
.invokeAction({} as ZappEntry);
|
|
363
390
|
|
|
364
|
-
expect(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
391
|
+
expect(
|
|
392
|
+
(openBottomSheetModal as jest.Mock).mock.calls.map(
|
|
393
|
+
([arg]) => arg.modalBottomSheetContentProps.title
|
|
394
|
+
)
|
|
395
|
+
).toEqual(["Playback Speed", "Sleep Timer"]);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("falls back to sheet width when audio modal theme spacing keys are absent", () => {
|
|
399
|
+
expect(getBottomSheetModalLabelProps({}, 375).maxWidth).toBe(375);
|
|
368
400
|
});
|
|
369
401
|
});
|
|
@@ -7,10 +7,18 @@ import { ActionHandler } from "@applicaster/zapp-react-native-utils/actionsExecu
|
|
|
7
7
|
import { uiActionsRegistry } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
|
|
8
8
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
9
9
|
import { modalOrchestrator } from "@applicaster/zapp-react-native-utils/modalState/ModalOrchestrator";
|
|
10
|
+
import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState/store";
|
|
10
11
|
import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
11
12
|
|
|
12
13
|
import { speedOptions } from "../Const/speedOptions";
|
|
13
14
|
import { getSleepTimerOptions } from "../Const/sleepTimerOptions";
|
|
15
|
+
import {
|
|
16
|
+
getBottomSheetModalDefaultItemIcon,
|
|
17
|
+
getBottomSheetModalIconProps,
|
|
18
|
+
getBottomSheetModalItemProps,
|
|
19
|
+
getBottomSheetModalLabelProps,
|
|
20
|
+
getBottomSheetModalSelectedItemIcon,
|
|
21
|
+
} from "../Utils";
|
|
14
22
|
import { formatSpeed } from "./utils";
|
|
15
23
|
import { SpeedController } from "./SpeedManager";
|
|
16
24
|
import { SleepTimerController, SleepTimerState } from "./SleepTimerManager";
|
|
@@ -41,24 +49,14 @@ function dismissOpenedSheet(action: ActionType) {
|
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
title,
|
|
53
|
-
extensions: {
|
|
54
|
-
tap_actions: {
|
|
55
|
-
actions: [
|
|
56
|
-
{ type: actionType, options: { ...options, dismissSheet: true } },
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
} as ZappEntry;
|
|
61
|
-
}
|
|
52
|
+
const AUDIO_PICKER_SHEET_STYLE_PROPS = {
|
|
53
|
+
itemProps: getBottomSheetModalItemProps,
|
|
54
|
+
iconProps: getBottomSheetModalIconProps,
|
|
55
|
+
labelProps: getBottomSheetModalLabelProps,
|
|
56
|
+
getSelectedItemIcon: getBottomSheetModalSelectedItemIcon,
|
|
57
|
+
getDefaultItemIcon: getBottomSheetModalDefaultItemIcon,
|
|
58
|
+
iconPlacement: "right" as const,
|
|
59
|
+
};
|
|
62
60
|
|
|
63
61
|
function sleepTimerEntryState(
|
|
64
62
|
sleepState: SleepTimerState
|
|
@@ -97,31 +95,25 @@ export async function openPlaybackSpeedAction(
|
|
|
97
95
|
const config = getPlayerConfig();
|
|
98
96
|
const current = speedController.currentSpeed;
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
content: {
|
|
117
|
-
behavior: {
|
|
118
|
-
selectMode: "single",
|
|
119
|
-
currentSelection: [String(current.value)],
|
|
120
|
-
},
|
|
121
|
-
items,
|
|
122
|
-
},
|
|
98
|
+
openBottomSheetModal({
|
|
99
|
+
modalBottomSheetContentProps: {
|
|
100
|
+
key: PLAYER_ACTION_IDENTIFIERS.PLAYBACK_SPEED,
|
|
101
|
+
title: config.playback_speed_title || "Playback Speed",
|
|
102
|
+
items: speedOptions.map((option) => ({
|
|
103
|
+
...option,
|
|
104
|
+
id: String(option.value),
|
|
105
|
+
})),
|
|
106
|
+
current_selection: current,
|
|
107
|
+
onPress: (item) =>
|
|
108
|
+
actionExecutor.handleAction({
|
|
109
|
+
type: PLAYER_ACTION_TYPES.SET_PLAYBACK_SPEED,
|
|
110
|
+
options: { value: item.value },
|
|
111
|
+
}),
|
|
112
|
+
...AUDIO_PICKER_SHEET_STYLE_PROPS,
|
|
123
113
|
},
|
|
124
|
-
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return ActionResult.Success;
|
|
125
117
|
}
|
|
126
118
|
|
|
127
119
|
export async function openSleepTimerAction(
|
|
@@ -136,33 +128,27 @@ export async function openSleepTimerAction(
|
|
|
136
128
|
timerRemaining
|
|
137
129
|
)
|
|
138
130
|
.filter(Boolean)
|
|
139
|
-
.map((option) =>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
behavior: {
|
|
157
|
-
selectMode: "single",
|
|
158
|
-
currentSelection: timerRemaining
|
|
159
|
-
? [String(sleepState.timer.value)]
|
|
160
|
-
: [],
|
|
161
|
-
},
|
|
162
|
-
items,
|
|
163
|
-
},
|
|
131
|
+
.map((option) => ({
|
|
132
|
+
...option,
|
|
133
|
+
id: String(option.value),
|
|
134
|
+
}));
|
|
135
|
+
|
|
136
|
+
openBottomSheetModal({
|
|
137
|
+
modalBottomSheetContentProps: {
|
|
138
|
+
key: PLAYER_ACTION_IDENTIFIERS.SLEEP_TIMER,
|
|
139
|
+
title: config.playback_sleep_title || "Sleep Timer",
|
|
140
|
+
items,
|
|
141
|
+
current_selection: timerRemaining ? sleepState.timer : null,
|
|
142
|
+
onPress: (item) =>
|
|
143
|
+
actionExecutor.handleAction({
|
|
144
|
+
type: PLAYER_ACTION_TYPES.SET_SLEEP_TIMER,
|
|
145
|
+
options: { value: item.value, label: item.label },
|
|
146
|
+
}),
|
|
147
|
+
...AUDIO_PICKER_SHEET_STYLE_PROPS,
|
|
164
148
|
},
|
|
165
|
-
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return ActionResult.Success;
|
|
166
152
|
}
|
|
167
153
|
|
|
168
154
|
export async function setPlaybackSpeedAction(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
2
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
2
3
|
|
|
3
4
|
export * from "./Utils";
|
|
4
5
|
|
|
@@ -38,15 +39,20 @@ export const getBottomSheetModalLabelProps = (theme, width: number) => {
|
|
|
38
39
|
audio_modal_bottom_sheet_item_padding_right,
|
|
39
40
|
} = theme;
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const calculatedMaxWidth =
|
|
42
43
|
width -
|
|
43
|
-
(audio_modal_bottom_sheet_item_icon_width +
|
|
44
|
-
audio_modal_bottom_sheet_item_icon_margin_left +
|
|
45
|
-
audio_modal_bottom_sheet_item_icon_margin_right +
|
|
46
|
-
audio_modal_bottom_sheet_item_margin_left +
|
|
47
|
-
audio_modal_bottom_sheet_item_margin_right +
|
|
48
|
-
audio_modal_bottom_sheet_item_padding_left +
|
|
49
|
-
audio_modal_bottom_sheet_item_padding_right);
|
|
44
|
+
(toNumberWithDefaultZero(audio_modal_bottom_sheet_item_icon_width) +
|
|
45
|
+
toNumberWithDefaultZero(audio_modal_bottom_sheet_item_icon_margin_left) +
|
|
46
|
+
toNumberWithDefaultZero(audio_modal_bottom_sheet_item_icon_margin_right) +
|
|
47
|
+
toNumberWithDefaultZero(audio_modal_bottom_sheet_item_margin_left) +
|
|
48
|
+
toNumberWithDefaultZero(audio_modal_bottom_sheet_item_margin_right) +
|
|
49
|
+
toNumberWithDefaultZero(audio_modal_bottom_sheet_item_padding_left) +
|
|
50
|
+
toNumberWithDefaultZero(audio_modal_bottom_sheet_item_padding_right));
|
|
51
|
+
|
|
52
|
+
const maxWidth =
|
|
53
|
+
Number.isNaN(calculatedMaxWidth) || calculatedMaxWidth <= 0
|
|
54
|
+
? width
|
|
55
|
+
: calculatedMaxWidth;
|
|
50
56
|
|
|
51
57
|
return {
|
|
52
58
|
fontFamily: platformSelect({
|