@applicaster/quick-brick-player 12.0.4 → 12.0.5-alpha.1340200034

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": "12.0.4",
3
+ "version": "12.0.5-alpha.1340200034",
4
4
  "description": "Quick Brick Player",
5
5
  "main": "./src/index.ts",
6
6
  "types": "index.d.ts",
@@ -36,11 +36,11 @@
36
36
  },
37
37
  "homepage": "https://github.com/applicaster/quickbrick#readme",
38
38
  "dependencies": {
39
- "@applicaster/quick-brick-mobile-transport-controls": "12.0.4",
39
+ "@applicaster/quick-brick-mobile-transport-controls": "12.0.5-rc.0",
40
40
  "@applicaster/quick-brick-tv-transport-controls": "12.0.4",
41
- "@applicaster/zapp-react-native-tvos-app": "12.0.4",
42
- "@applicaster/zapp-react-native-ui-components": "12.0.4",
43
- "@applicaster/zapp-react-native-utils": "12.0.4",
41
+ "@applicaster/zapp-react-native-tvos-app": "12.0.5-alpha.1340200034",
42
+ "@applicaster/zapp-react-native-ui-components": "12.0.5-alpha.1340200034",
43
+ "@applicaster/zapp-react-native-utils": "12.0.5-alpha.1340200034",
44
44
  "keymirror": "^0.1.1",
45
45
  "query-string": "7.1.3",
46
46
  "react-native-web-linear-gradient": "1.1.2",
@@ -15,7 +15,7 @@ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
15
15
  import { PlayNextData } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
16
16
  import { PlayerDetails } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/PlayerDetails";
17
17
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
18
- import { useEffect, useState } from "react";
18
+ import { useCallback, useEffect, useState } from "react";
19
19
  import { MagicBG } from "./MagicBG";
20
20
  import {
21
21
  formatSpeed,
@@ -33,6 +33,13 @@ import {
33
33
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
34
34
  import { PADDING_HORIZONTAL } from "./Layout/defaultLayoutsConts";
35
35
  import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
36
+ import {
37
+ speed_0_8,
38
+ speed_1,
39
+ speed_1_2,
40
+ speed_1_5,
41
+ speed_2,
42
+ } from "@applicaster/quick-brick-mobile-transport-controls";
36
43
 
37
44
  const { log_debug } = createLogger({
38
45
  subsystem: "UIComponent",
@@ -132,11 +139,11 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
132
139
  } = props;
133
140
 
134
141
  const speeds = [
135
- { asset: configuration["speed_0_8"], value: 0.8 },
136
- { asset: configuration["speed_1"], value: 1.0 },
137
- { asset: configuration["speed_1_2"], value: 1.2 },
138
- { asset: configuration["speed_1_5"], value: 1.5 },
139
- { asset: configuration["speed_2"], value: 2.0 },
142
+ { asset: configuration["speed_0_8"] || speed_0_8, value: 0.8 },
143
+ { asset: configuration["speed_1"] || speed_1, value: 1.0 },
144
+ { asset: configuration["speed_1_2"] || speed_1_2, value: 1.2 },
145
+ { asset: configuration["speed_1_5"] || speed_1_5, value: 1.5 },
146
+ { asset: configuration["speed_2"] || speed_2, value: 2.0 },
140
147
  ];
141
148
 
142
149
  const isTablet = useIsTablet();
@@ -189,7 +196,7 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
189
196
  if (!defaultDimensions) setDefaultDimensions({ width, height });
190
197
  };
191
198
 
192
- const cancelSleepTimer = async () => {
199
+ const cancelSleepTimer = useCallback(async () => {
193
200
  player?.cancelSleepTimer();
194
201
 
195
202
  setSleepTimer({
@@ -200,46 +207,47 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
200
207
  setSleepTimerDate(0);
201
208
 
202
209
  await localStorage.removeItem("sleep", NAMESPACE);
203
- };
204
-
205
- const startSleepTimer = (timerValue: number) => {
206
- try {
207
- const currentDate = new Date();
208
- const futureDate = new Date(currentDate.getTime() + timerValue * 60000);
209
- const futureSleepDate = futureDate.getTime();
210
+ }, [player, setSleepTimer, setSleepTimerDate]);
210
211
 
211
- player?.cancelSleepTimer();
212
+ const startSleepTimer = useCallback(
213
+ (timerValue: number) => {
214
+ try {
215
+ const futureSleepDate = Date.now() + timerValue * 60000;
212
216
 
213
- player?.startSleepTimer(futureSleepDate);
217
+ player?.cancelSleepTimer?.();
214
218
 
215
- return futureSleepDate;
216
- } catch (e) {
217
- return 0;
218
- }
219
- };
220
-
221
- const handleSleep = async (
222
- timerValue: number,
223
- currentFutureSleepDate = null
224
- ) => {
225
- if (currentFutureSleepDate) {
226
- if (hasDatePassed(currentFutureSleepDate)) {
227
- await cancelSleepTimer();
219
+ player?.startSleepTimer?.(futureSleepDate);
228
220
 
221
+ return futureSleepDate;
222
+ } catch (e) {
229
223
  return 0;
230
224
  }
225
+ },
226
+ [player]
227
+ );
231
228
 
232
- return currentFutureSleepDate;
233
- }
229
+ const handleSleep = useCallback(
230
+ async (timerValue: number, currentFutureSleepDate = null) => {
231
+ if (currentFutureSleepDate) {
232
+ if (hasDatePassed(currentFutureSleepDate)) {
233
+ await cancelSleepTimer();
234
234
 
235
- if (timerValue === 0) {
236
- await cancelSleepTimer();
235
+ return 0;
236
+ }
237
237
 
238
- return timerValue;
239
- }
238
+ return currentFutureSleepDate;
239
+ }
240
240
 
241
- return startSleepTimer(timerValue);
242
- };
241
+ if (timerValue === 0) {
242
+ await cancelSleepTimer();
243
+
244
+ return timerValue;
245
+ }
246
+
247
+ return startSleepTimer(timerValue);
248
+ },
249
+ [startSleepTimer, cancelSleepTimer]
250
+ );
243
251
 
244
252
  useEffect(() => {
245
253
  const loadSpeed = async () => {
@@ -262,9 +270,16 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
262
270
  }
263
271
  };
264
272
 
265
- loadSpeed().then();
266
- loadSleep().then();
267
- }, [playerState.isReadyToPlay]);
273
+ void loadSpeed();
274
+ void loadSleep();
275
+ }, [
276
+ playerState.isReadyToPlay,
277
+ handleSleep,
278
+ setSleepTimer,
279
+ setSleepTimerDate,
280
+ setPlaybackSpeed,
281
+ player,
282
+ ]);
268
283
 
269
284
  const getValue = (key: string, stylesObj: {}) =>
270
285
  R.propOr(null, key, stylesObj);
@@ -292,7 +307,7 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
292
307
 
293
308
  const onPlaybackButtonPress = React.useCallback(() => {
294
309
  if (playerState.isBuffering) return;
295
- playerState.isPaused ? player?.play() : player.pause();
310
+ playerState.isPaused ? player?.play() : player?.pause();
296
311
  }, [playerState, player]);
297
312
 
298
313
  const seekDuration = toNumberWithDefault(10, value("seek_duration"));
@@ -308,7 +323,7 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
308
323
  const onSpeedSelect = React.useCallback(
309
324
  async (item) => {
310
325
  setPlaybackSpeed(item);
311
- player.setPlaybackRate(item.value);
326
+ player?.setPlaybackRate(item.value);
312
327
  await localStorage.setItem("speed", item, NAMESPACE);
313
328
  },
314
329
  [player, setPlaybackSpeed]
@@ -326,7 +341,7 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
326
341
  NAMESPACE
327
342
  );
328
343
  },
329
- [player, setSleepTimer]
344
+ [setSleepTimer, setSleepTimerDate, handleSleep]
330
345
  );
331
346
 
332
347
  const onSpeedButtonPress = React.useCallback(() => {
@@ -341,13 +356,22 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
341
356
  supportedOrientations: ["portrait"],
342
357
  },
343
358
  });
344
- }, [playbackSpeed, setPlaybackSpeed]);
359
+ }, [
360
+ playbackSpeed,
361
+ setPlaybackSpeed,
362
+ navigator,
363
+ onSpeedSelect,
364
+ configuration["playback_speed_title"],
365
+ ]);
345
366
 
346
367
  const onSleepButtonPress = React.useCallback(() => {
347
368
  navigator.openModalBottomSheet({
348
369
  modalBottomSheetContentProps: {
349
370
  items: [
350
- { label: configuration["playback_sleep_off_label"], value: 0 },
371
+ {
372
+ label: configuration["playback_sleep_off_label"],
373
+ value: 0,
374
+ },
351
375
  ].concat(sleeps),
352
376
  current_selection: sleepTimer,
353
377
  onPress: onSleepSelect,
@@ -357,7 +381,13 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
357
381
  supportedOrientations: ["portrait"],
358
382
  },
359
383
  });
360
- }, [sleepTimer, setSleepTimer, configuration]);
384
+ }, [
385
+ navigator,
386
+ sleepTimer,
387
+ configuration["playback_sleep_title"],
388
+ configuration["playback_sleep_off_label"],
389
+ onSleepSelect,
390
+ ]);
361
391
 
362
392
  const onCloseVideoModal = React.useCallback(() => {
363
393
  playerManager.close();