@applicaster/quick-brick-player 17.0.0-alpha.3352797522 → 17.0.0-alpha.9147048829
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 +6 -6
- package/src/Player/AudioLayer/Layout/Controls/__tests__/utils.test.ts +48 -0
- package/src/Player/AudioLayer/Layout/DockedControls/__tests__/controlButtons.test.ts +86 -0
- package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +1 -1
- package/src/Player/AudioLayer/__tests__/playerActions.test.ts +74 -42
- package/src/Player/AudioLayer/playerActions.ts +54 -70
- package/src/Player/Utils/index.tsx +14 -8
- package/src/Player/__tests__/mobileControls.test.ts +35 -0
- package/src/Player/index.tsx +47 -11
- package/src/Player/mobileControls.ts +7 -0
- package/src/Player/mobileControls.web.ts +10 -0
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.9147048829",
|
|
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": "
|
|
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.9147048829",
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components": "17.0.0-alpha.9147048829",
|
|
42
|
+
"@applicaster/zapp-react-native-utils": "17.0.0-alpha.9147048829",
|
|
43
43
|
"query-string": "7.1.3",
|
|
44
44
|
"shaka-player": "4.3.5",
|
|
45
45
|
"typeface-montserrat": "^0.0.54",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
controlsRowActionIdentifiers,
|
|
3
3
|
nextTrackButton,
|
|
4
|
+
playbackButton,
|
|
4
5
|
previousTrackButton,
|
|
5
6
|
usesPlaylistControls,
|
|
6
7
|
} from "../utils";
|
|
@@ -85,3 +86,50 @@ describe("track control buttons", () => {
|
|
|
85
86
|
).toMatchObject({ disabled: true });
|
|
86
87
|
});
|
|
87
88
|
});
|
|
89
|
+
|
|
90
|
+
describe("playbackButton icon state", () => {
|
|
91
|
+
const basePlayerState = {
|
|
92
|
+
currentTime: 10,
|
|
93
|
+
duration: 120,
|
|
94
|
+
seekableDuration: 120,
|
|
95
|
+
isLive: false,
|
|
96
|
+
isPaused: false,
|
|
97
|
+
isBuffering: false,
|
|
98
|
+
isReadyToPlay: true,
|
|
99
|
+
isAd: false,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
it("shows pause icon while playing and play icon when paused by interruption", () => {
|
|
103
|
+
const playingButton = playbackButton({
|
|
104
|
+
playerState: { ...basePlayerState, isPaused: false },
|
|
105
|
+
liveButton: false,
|
|
106
|
+
isTablet: false,
|
|
107
|
+
isLiveShowFullControls: false,
|
|
108
|
+
onPress: jest.fn(),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(playingButton.icon).toBe("pause");
|
|
112
|
+
|
|
113
|
+
const pausedButton = playbackButton({
|
|
114
|
+
playerState: { ...basePlayerState, isPaused: true },
|
|
115
|
+
liveButton: false,
|
|
116
|
+
isTablet: false,
|
|
117
|
+
isLiveShowFullControls: false,
|
|
118
|
+
onPress: jest.fn(),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(pausedButton.icon).toBe("play");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("shows buffering icon when buffering even if not paused", () => {
|
|
125
|
+
const bufferingButton = playbackButton({
|
|
126
|
+
playerState: { ...basePlayerState, isPaused: false, isBuffering: true },
|
|
127
|
+
liveButton: false,
|
|
128
|
+
isTablet: false,
|
|
129
|
+
isLiveShowFullControls: false,
|
|
130
|
+
onPress: jest.fn(),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(bufferingButton.icon).toBe("buffering");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
jest.mock(
|
|
2
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight",
|
|
3
|
+
() => ({
|
|
4
|
+
getTabBarHeight: () => 56,
|
|
5
|
+
})
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
jest.mock(
|
|
9
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
10
|
+
() => ({
|
|
11
|
+
useNavigation: () => ({}),
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
16
|
+
useIsTablet: () => false,
|
|
17
|
+
useZStore: () => () => ({}),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock("@applicaster/zapp-react-native-utils/appUtils", () => ({
|
|
21
|
+
playerManager: {
|
|
22
|
+
isCasting: () => false,
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
jest.mock(
|
|
27
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerState",
|
|
28
|
+
() => ({
|
|
29
|
+
usePlayerState: () => ({}),
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
jest.mock(
|
|
34
|
+
"@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils",
|
|
35
|
+
() => ({
|
|
36
|
+
useConfiguration: () => ({}),
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
jest.mock(
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils",
|
|
42
|
+
() => ({
|
|
43
|
+
PROGRESS_BAR_HEIGHT: 2,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
jest.mock(
|
|
48
|
+
"@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler",
|
|
49
|
+
() => ({
|
|
50
|
+
isBottomTabVisible: () => false,
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
jest.mock("@applicaster/zapp-react-native-redux", () => ({
|
|
55
|
+
usePlugins: () => [],
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
jest.mock("@applicaster/quick-brick-mobile-transport-controls", () => ({
|
|
59
|
+
Button: () => null,
|
|
60
|
+
ContentInfo: () => null,
|
|
61
|
+
Controls: () => null,
|
|
62
|
+
ProgressBar: () => null,
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
import { controlButtons } from "../index";
|
|
66
|
+
|
|
67
|
+
describe("DockedControls controlButtons icon state", () => {
|
|
68
|
+
it("shows pause_mini while playing and play_mini when paused", () => {
|
|
69
|
+
expect(controlButtons(false, false, false, "player-1")[0]).toMatchObject({
|
|
70
|
+
icon: "pause_mini",
|
|
71
|
+
name: "pause",
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(controlButtons(false, true, false, "player-1")[0]).toMatchObject({
|
|
75
|
+
icon: "play_mini",
|
|
76
|
+
name: "play",
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("shows buffering when buffering", () => {
|
|
81
|
+
expect(controlButtons(false, false, true, "player-1")[0]).toMatchObject({
|
|
82
|
+
icon: "buffering",
|
|
83
|
+
name: "buffering",
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -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,32 +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
|
-
role: "collection_selector",
|
|
118
|
-
behavior: {
|
|
119
|
-
selectMode: "single",
|
|
120
|
-
currentSelection: [String(current.value)],
|
|
121
|
-
},
|
|
122
|
-
items,
|
|
123
|
-
},
|
|
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,
|
|
124
113
|
},
|
|
125
|
-
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return ActionResult.Success;
|
|
126
117
|
}
|
|
127
118
|
|
|
128
119
|
export async function openSleepTimerAction(
|
|
@@ -137,34 +128,27 @@ export async function openSleepTimerAction(
|
|
|
137
128
|
timerRemaining
|
|
138
129
|
)
|
|
139
130
|
.filter(Boolean)
|
|
140
|
-
.map((option) =>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
role: "collection_selector",
|
|
158
|
-
behavior: {
|
|
159
|
-
selectMode: "single",
|
|
160
|
-
currentSelection: timerRemaining
|
|
161
|
-
? [String(sleepState.timer.value)]
|
|
162
|
-
: [],
|
|
163
|
-
},
|
|
164
|
-
items,
|
|
165
|
-
},
|
|
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,
|
|
166
148
|
},
|
|
167
|
-
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return ActionResult.Success;
|
|
168
152
|
}
|
|
169
153
|
|
|
170
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({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
|
+
|
|
4
|
+
import * as mobileControls from "../mobileControls";
|
|
5
|
+
import * as webStandIns from "../mobileControls.web";
|
|
6
|
+
|
|
7
|
+
describe("mobile player controls in web builds", () => {
|
|
8
|
+
const originalOS = Platform.OS;
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
Platform.OS = originalOS;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// The web stand-ins are safe only because Player renders `isTV() ? renderTV() : renderMobile()`.
|
|
15
|
+
it.each(["web", "samsung_tv", "lg_tv"])(
|
|
16
|
+
"%s always takes the TV render path",
|
|
17
|
+
(platform) => {
|
|
18
|
+
Platform.OS = platform as typeof Platform.OS;
|
|
19
|
+
|
|
20
|
+
expect(isTV()).toBe(true);
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
it("provides every control the mobile module exports", () => {
|
|
25
|
+
expect(Object.keys(webStandIns).sort()).toEqual(
|
|
26
|
+
Object.keys(mobileControls).sort()
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("renders nothing for each stand-in", () => {
|
|
31
|
+
Object.values(webStandIns).forEach((StandIn) => {
|
|
32
|
+
expect((StandIn as () => null)()).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
package/src/Player/index.tsx
CHANGED
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import * as R from "ramda";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Dimensions,
|
|
10
|
+
findNodeHandle,
|
|
11
|
+
StyleSheet,
|
|
12
|
+
View,
|
|
13
|
+
ViewStyle,
|
|
14
|
+
} from "react-native";
|
|
9
15
|
|
|
10
|
-
import TransportControlsMobile, {
|
|
11
|
-
ErrorOverlay,
|
|
12
|
-
} from "@applicaster/quick-brick-mobile-transport-controls";
|
|
13
16
|
import TransportControlsTV, {
|
|
14
17
|
ErrorOverlay as TVErrorOverlay,
|
|
15
18
|
} from "@applicaster/quick-brick-tv-transport-controls";
|
|
@@ -27,6 +30,7 @@ import {
|
|
|
27
30
|
PlayerDetails,
|
|
28
31
|
PlayerWrapper,
|
|
29
32
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
|
|
33
|
+
import { getVerticalColumnWidth } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/playerWrapperUtils";
|
|
30
34
|
|
|
31
35
|
import { PlayNextOverlay } from "./PlayNextOverlay";
|
|
32
36
|
import { PlayerImageBackground } from "@applicaster/zapp-react-native-ui-components/Components/PlayerImageBackground";
|
|
@@ -47,10 +51,15 @@ import {
|
|
|
47
51
|
isAudioItem as isAudioItemUtil,
|
|
48
52
|
isInlineTV as isInlineTVUtil,
|
|
49
53
|
} from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
54
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
50
55
|
|
|
51
56
|
import { TVPlayerView } from "./PlayerView/TVPlayerView";
|
|
52
57
|
import PlayerModal, { VideoPlayerModal } from "./PlayerModal";
|
|
53
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
DockedControls,
|
|
60
|
+
ErrorOverlay,
|
|
61
|
+
TransportControlsMobile,
|
|
62
|
+
} from "./mobileControls";
|
|
54
63
|
import { FlexImage } from "./AudioLayer/Layout/PlayerImage/FlexImage";
|
|
55
64
|
import { PlayerError } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/const";
|
|
56
65
|
|
|
@@ -1390,8 +1399,31 @@ export default class VideoPlayer extends React.Component<
|
|
|
1390
1399
|
|
|
1391
1400
|
const shouldRenderNativePlayer = !isCasting || this.supportNativeCast;
|
|
1392
1401
|
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1402
|
+
const isVerticalInlineTabletLandscape =
|
|
1403
|
+
vertical &&
|
|
1404
|
+
inline &&
|
|
1405
|
+
isModal &&
|
|
1406
|
+
!piped &&
|
|
1407
|
+
getIsTablet() &&
|
|
1408
|
+
!isTabletPortrait;
|
|
1409
|
+
|
|
1410
|
+
// Vertical inline on a landscape tablet fills the column height. The
|
|
1411
|
+
// minimise animation and the docked slot both use this ratio, so it has to
|
|
1412
|
+
// describe that box, not 16:9, and both sides have to come from the same
|
|
1413
|
+
// window the layout measures -- getTabletWidth resolves percentages
|
|
1414
|
+
// against the device screen, which is wider than the app in split view.
|
|
1415
|
+
const verticalColumnWidth = isVerticalInlineTabletLandscape
|
|
1416
|
+
? getVerticalColumnWidth(
|
|
1417
|
+
Dimensions.get("window").width,
|
|
1418
|
+
pluginConfiguration.tablet_landscape_sidebar_width
|
|
1419
|
+
)
|
|
1420
|
+
: undefined;
|
|
1421
|
+
|
|
1422
|
+
const aspectRatio = isVerticalInlineTabletLandscape
|
|
1423
|
+
? verticalColumnWidth / Dimensions.get("window").height
|
|
1424
|
+
: !inline && isModal && !piped
|
|
1425
|
+
? getScreenAspectRatio()
|
|
1426
|
+
: 16 / 9;
|
|
1395
1427
|
|
|
1396
1428
|
const audioPlayerProps = {
|
|
1397
1429
|
ref: this._assignRoot,
|
|
@@ -1432,10 +1464,14 @@ export default class VideoPlayer extends React.Component<
|
|
|
1432
1464
|
fullscreen={fullscreen}
|
|
1433
1465
|
modal
|
|
1434
1466
|
style={{
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1467
|
+
// The modal freezes this as the player width, so it has to be the
|
|
1468
|
+
// same column the aspect ratio above describes.
|
|
1469
|
+
tabletLandscapeWidth:
|
|
1470
|
+
verticalColumnWidth ??
|
|
1471
|
+
getTabletWidth(
|
|
1472
|
+
this.getPluginConfiguration().tablet_landscape_sidebar_width,
|
|
1473
|
+
style
|
|
1474
|
+
),
|
|
1439
1475
|
width: style.width,
|
|
1440
1476
|
height: style.height,
|
|
1441
1477
|
}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Controls only the mobile player renders (Player's renderMobile path). Web builds resolve mobileControls.web.ts.
|
|
2
|
+
export {
|
|
3
|
+
default as TransportControlsMobile,
|
|
4
|
+
ErrorOverlay,
|
|
5
|
+
} from "@applicaster/quick-brick-mobile-transport-controls";
|
|
6
|
+
|
|
7
|
+
export { DockedControls } from "./AudioLayer/Layout/DockedControls";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Web builds always render the TV player: Player renders `isTV() ? renderTV() : renderMobile()`, and isTV() is true on
|
|
2
|
+
// every web platform. The mobile controls are never rendered there, so web bundles get empty stand-ins and leave the
|
|
3
|
+
// mobile transport controls package out.
|
|
4
|
+
const NotRenderedOnWeb = () => null;
|
|
5
|
+
|
|
6
|
+
export const TransportControlsMobile = NotRenderedOnWeb;
|
|
7
|
+
|
|
8
|
+
export const ErrorOverlay = NotRenderedOnWeb;
|
|
9
|
+
|
|
10
|
+
export const DockedControls = NotRenderedOnWeb;
|