@applicaster/quick-brick-player 12.0.0-alpha.3479552302 → 12.0.0-alpha.3493135603

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.0-alpha.3479552302",
3
+ "version": "12.0.0-alpha.3493135603",
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.0-rc.33",
40
- "@applicaster/quick-brick-tv-transport-controls": "11.0.0-rc.133",
41
- "@applicaster/zapp-react-native-tvos-app": "12.0.0-alpha.3479552302",
42
- "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.3479552302",
43
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.3479552302",
39
+ "@applicaster/quick-brick-mobile-transport-controls": "12.0.0-rc.118",
40
+ "@applicaster/quick-brick-tv-transport-controls": "12.0.0-alpha.3493135603",
41
+ "@applicaster/zapp-react-native-tvos-app": "12.0.0-alpha.3493135603",
42
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.3493135603",
43
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.3493135603",
44
44
  "keymirror": "^0.1.1",
45
45
  "query-string": "7.1.3",
46
46
  "react-native-web-linear-gradient": "1.1.2",
@@ -10,66 +10,76 @@ type Asset = string | undefined;
10
10
  const isCurrentPlayer = (playerId) =>
11
11
  LiveImageManager.instance.getCurrentlyPlaying()?.playerId === playerId;
12
12
 
13
+ const liveImageButtonsListenerKey = "live-image-buttons";
14
+
13
15
  const usePlayPauseListeners = (playerId, player, asset, setImageUri) =>
14
16
  useEffect(() => {
15
17
  if (playerId && player) {
16
- if (player.playerState.isReadyToPlay) {
17
- if (player.playerState.isPaused) {
18
- setImageUri(asset.active);
19
- } else {
20
- setImageUri(asset.inactive);
21
- }
18
+ setImageUri(null);
19
+
20
+ return;
21
+ }
22
+
23
+ if (player.playerState.isReadyToPlay) {
24
+ if (player.playerState.isPaused) {
25
+ setImageUri(asset.active);
26
+ } else {
27
+ setImageUri(asset.inactive);
22
28
  }
29
+ }
23
30
 
24
- return player.addListener({
25
- id: "live-image-buttons",
26
- listener: {
27
- onPlayerResume: () => {
28
- setImageUri(asset.inactive);
29
- },
30
- onPlayerPause: () => {
31
- setImageUri(asset.active);
32
- },
33
- onPlayerClose: () => {
34
- setImageUri(null);
35
- },
36
- onLoad() {
37
- setImageUri(asset.inactive);
38
- },
31
+ return player.addListener({
32
+ id: liveImageButtonsListenerKey,
33
+ listener: {
34
+ onPlayerResume: () => {
35
+ setImageUri(asset.inactive);
39
36
  },
40
- });
41
- }
37
+ onPlayerPause: () => {
38
+ setImageUri(asset.active);
39
+ },
40
+ onPlayerClose: () => {
41
+ setImageUri(null);
42
+ },
43
+ onLoad() {
44
+ setImageUri(asset.inactive);
45
+ },
46
+ },
47
+ });
42
48
  }, [player, playerId, asset]);
43
49
 
44
50
  const useMuteUnmuteListeners = (playerId, player, asset, setImageUri) =>
45
51
  useEffect(() => {
46
- if (playerId && player) {
47
- // active action = muted, inactive = unmuted
48
- return player.addListener({
49
- id: "live-image-buttons",
50
- listener: {
51
- onPlayerMute: () => {
52
- if (isCurrentPlayer(playerId)) {
53
- setImageUri(asset.active);
54
- }
55
- },
56
- onPlayerUnmute: () => {
57
- if (isCurrentPlayer(playerId)) {
58
- setImageUri(asset.inactive);
59
- }
60
- },
61
- onLoad() {
62
- setImageUri(player?.getIsMuted() ? asset.active : asset.inactive);
63
- },
64
- onPlayerClose: () => {
65
- setImageUri(null);
66
- },
67
- onVideoEnd: () => {
68
- setImageUri(null);
69
- },
70
- },
71
- });
52
+ if (!player || !playerId) {
53
+ setImageUri(null);
54
+
55
+ return;
72
56
  }
57
+
58
+ // active action = muted, inactive = unmuted
59
+ return player.addListener({
60
+ id: liveImageButtonsListenerKey,
61
+ listener: {
62
+ onPlayerMute: () => {
63
+ if (isCurrentPlayer(playerId)) {
64
+ setImageUri(asset.active);
65
+ }
66
+ },
67
+ onPlayerUnmute: () => {
68
+ if (isCurrentPlayer(playerId)) {
69
+ setImageUri(asset.inactive);
70
+ }
71
+ },
72
+ onLoad() {
73
+ setImageUri(player?.getIsMuted() ? asset.active : asset.inactive);
74
+ },
75
+ onPlayerClose: () => {
76
+ setImageUri(null);
77
+ },
78
+ onVideoEnd: () => {
79
+ setImageUri(null);
80
+ },
81
+ },
82
+ });
73
83
  }, [player, playerId, asset]);
74
84
 
75
85
  const useListeners = MUTED_USAGE
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { memo } from "react";
2
2
  import { LiveImageManager } from "@applicaster/zapp-react-native-ui-components/Components/VideoLive/LiveImageManager";
3
3
 
4
4
  import { Context } from "./Context";
@@ -21,7 +21,7 @@ const playActionCallback = (player) => {
21
21
  }
22
22
  };
23
23
 
24
- const invokeAction = () => {
24
+ const invokeAction = (_item: ZappEntry, _object) => {
25
25
  const actionCallback = MUTED_USAGE ? muteActionCallback : playActionCallback;
26
26
  // We only allow one player to be present at a time
27
27
  const player = LiveImageManager.instance.getCurrentlyPlaying()?.player;
@@ -29,6 +29,54 @@ const invokeAction = () => {
29
29
  actionCallback(player);
30
30
  };
31
31
 
32
+ // Not exported because currently the is no way
33
+ // to subscribe to the action availability change.
34
+ // We currently return a null state to disable the action.
35
+ // eslint-disable-next-line unused-imports/no-unused-vars
36
+ const isActionAvailable = (item: ZappEntry) => {
37
+ return (
38
+ LiveImageManager.instance.getCurrentlyPlaying()?.getPlayer().entry.id ===
39
+ item.id
40
+ );
41
+ };
42
+
43
+ const addListener = (
44
+ entryId: string,
45
+ listener: CellActionStateListenerFunction
46
+ ) => {
47
+ const callback = (event: Record<string, any>) => {
48
+ if (event.entry?.id !== entryId) {
49
+ return;
50
+ }
51
+
52
+ const player = LiveImageManager.instance.getCurrentlyPlaying()?.getPlayer();
53
+
54
+ if (!player || player.entry?.id !== entryId) {
55
+ listener(null);
56
+
57
+ return;
58
+ }
59
+
60
+ const actionState = MUTED_USAGE ? player.getIsMuted() : player.isPaused();
61
+
62
+ listener({
63
+ state: actionState ? 1 : 0,
64
+ label: "",
65
+ asset: AssetComponent,
66
+ });
67
+ };
68
+
69
+ return LiveImageManager.instance.addListener({
70
+ id: `cell-player-${entryId}`,
71
+ listener: {
72
+ onEnd: callback,
73
+ onStart: callback,
74
+ onError: callback,
75
+ onDestroy: callback,
76
+ },
77
+ });
78
+ };
79
+
32
80
  const emptyState = [];
33
81
 
34
82
  const initialEntryState = () => ({
@@ -38,7 +86,7 @@ const initialEntryState = () => ({
38
86
  });
39
87
 
40
88
  export function ContextProvider(Component: ReactComponent<any>) {
41
- return function DefaultPlayerProvider({
89
+ return memo(function DefaultPlayerProvider({
42
90
  children,
43
91
  }: CellActionContextProviderProps) {
44
92
  const contextValue = React.useMemo(
@@ -46,6 +94,7 @@ export function ContextProvider(Component: ReactComponent<any>) {
46
94
  state: emptyState,
47
95
  invokeAction,
48
96
  initialEntryState,
97
+ addListener,
49
98
  }),
50
99
  [invokeAction, initialEntryState]
51
100
  );
@@ -55,5 +104,5 @@ export function ContextProvider(Component: ReactComponent<any>) {
55
104
  <Component>{children}</Component>
56
105
  </Context.Provider>
57
106
  );
58
- };
107
+ });
59
108
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { ViewStyle, View, ScrollView } from "react-native";
2
+ import { ViewStyle, View } from "react-native";
3
3
 
4
4
  import { SafeAreaView, Edge } from "react-native-safe-area-context";
5
5
  import { usePlayerState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerState";
@@ -26,6 +26,13 @@ import {
26
26
  import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
27
27
  import { addQueryParam, getLiveUrl } from "../Utils";
28
28
  import { useTitleSummaryOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerTitleSummaryOverlay";
29
+ import {
30
+ AnimationComponent,
31
+ ComponentAnimationType,
32
+ AnimatedScrollModal,
33
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
34
+ import { PADDING_HORIZONTAL } from "./Layout/defaultLayoutsConts";
35
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
29
36
 
30
37
  const { log_debug } = createLogger({
31
38
  subsystem: "UIComponent",
@@ -68,29 +75,20 @@ export const defaultAspectRatioWidth = (height: number): number =>
68
75
  (height / 9) * 16;
69
76
 
70
77
  const Styles = {
71
- mainContainer: (docked: boolean, style: ViewStyle) => {
78
+ mainContainer: (style: ViewStyle) => {
72
79
  const combinedStyle: ViewStyle = {
73
80
  flex: 1,
74
81
  };
75
82
 
76
- if (!docked) {
77
- style.paddingTop = 0;
78
- style.paddingHorizontal = 15;
79
- }
80
-
81
- return { ...combinedStyle, ...style };
82
- },
83
- playerContainer: (docked: boolean, style: ViewStyle) => {
84
- const combinedStyle: ViewStyle = {
85
- flex: 1,
83
+ return {
84
+ ...combinedStyle,
85
+ ...style,
86
86
  };
87
-
88
- if (docked) {
89
- combinedStyle.height = style.height;
90
- }
91
-
92
- return combinedStyle;
93
87
  },
88
+ playerContainer: {
89
+ flex: 1,
90
+ },
91
+ paddingHorizontal: { paddingTop: 0, paddingHorizontal: PADDING_HORIZONTAL },
94
92
 
95
93
  controlsMobile: {
96
94
  height: 50,
@@ -168,6 +166,9 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
168
166
 
169
167
  const [sleepTimerDate, setSleepTimerDate] = useState(0);
170
168
 
169
+ const [defaultDimensions, setDefaultDimensions] =
170
+ React.useState<Dimensions>(undefined);
171
+
171
172
  const [dimensions, setDimensions] = React.useState<Dimensions>({
172
173
  width: 0,
173
174
  height: 0,
@@ -181,9 +182,11 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
181
182
  const { width, height } = event.nativeEvent.layout;
182
183
 
183
184
  setDimensions({
184
- width: docked ? defaultAspectRatioWidth(height) : width,
185
+ width,
185
186
  height,
186
187
  });
188
+
189
+ if (!defaultDimensions) setDefaultDimensions({ width, height });
187
190
  };
188
191
 
189
192
  const cancelSleepTimer = async () => {
@@ -292,7 +295,7 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
292
295
  playerState.isPaused ? player?.play() : player.pause();
293
296
  }, [playerState, player]);
294
297
 
295
- const seekDuration = Number(value("seek_duration"));
298
+ const seekDuration = toNumberWithDefault(10, value("seek_duration"));
296
299
 
297
300
  const onRewindButtonPress = React.useCallback(() => {
298
301
  player?.rewind(seekDuration);
@@ -375,58 +378,65 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
375
378
  player?.seekTo(0);
376
379
  }, [player]);
377
380
 
378
- const edges = React.useMemo<Edge[]>(
379
- () => (docked ? [] : ["right", "left", "top"]),
380
- [docked]
381
- );
381
+ const edges = React.useMemo<Edge[]>(() => ["right", "left", "top"], [docked]);
382
382
 
383
- const ContainerView = docked ? View : SafeAreaView;
383
+ const ContainerView = SafeAreaView;
384
384
 
385
385
  const MainContent = React.useMemo(() => {
386
386
  return (
387
- <ContainerView style={Styles.mainContainer(docked, style)} edges={edges}>
388
- <ScrollView
389
- style={Styles.playerContainer(docked, style)}
390
- onLayout={onLayout}
387
+ <ContainerView style={Styles.mainContainer(style)} edges={edges}>
388
+ <AnimationComponent
389
+ animationType={ComponentAnimationType.moveUpComponent}
390
+ additionalData={{ saveArea: true }}
391
+ style={Styles.playerContainer}
391
392
  >
392
- <Layout
393
- entry={entry}
394
- playerState={playerState}
395
- layoutState={layoutState}
396
- value={value}
397
- onPlaybackButtonPress={onPlaybackButtonPress}
398
- onRewindButtonPress={onRewindButtonPress}
399
- onForwardButtonPress={onForwardButtonPress}
400
- onPlayerSeek={onPlayerSeek}
401
- onSkipStart={onSkipStart}
402
- onSpeedButtonPress={onSpeedButtonPress}
403
- onSleepButtonPress={onSleepButtonPress}
404
- playbackSpeedName={formatSpeed(playbackSpeed.value)}
405
- playbackSleepName={
406
- sleepTimer.value === 0 ? "sleep_timer" : "sleep_timer_active"
407
- }
408
- sleepTimerDate={sleepTimerDate}
409
- cancelSleepTimer={cancelSleepTimer}
410
- onSkipLive={onSkipLive}
411
- onCloseVideoModal={onCloseVideoModal}
412
- maximiseVideoModal={maximiseVideoModal}
413
- configuration={configuration}
414
- dimensions={dimensions}
415
- playNextData={playNextData}
416
- title={title}
417
- summary={summary}
418
- />
419
- {children}
420
- {!docked && (
421
- <PlayerDetails
422
- configuration={configuration}
423
- style={Styles.playerDetails}
424
- entry={entry}
425
- isTabletLandscape={isTabletLandscape}
426
- isAudioPlayer={true}
427
- />
428
- )}
429
- </ScrollView>
393
+ <AnimatedScrollModal>
394
+ <View style={Styles.playerContainer} onLayout={onLayout}>
395
+ <Layout
396
+ entry={entry}
397
+ playerState={playerState}
398
+ layoutState={layoutState}
399
+ value={value}
400
+ onPlaybackButtonPress={onPlaybackButtonPress}
401
+ onRewindButtonPress={onRewindButtonPress}
402
+ onForwardButtonPress={onForwardButtonPress}
403
+ onPlayerSeek={onPlayerSeek}
404
+ onSkipStart={onSkipStart}
405
+ onSpeedButtonPress={onSpeedButtonPress}
406
+ onSleepButtonPress={onSleepButtonPress}
407
+ playbackSpeedName={formatSpeed(playbackSpeed.value)}
408
+ playbackSleepName={
409
+ sleepTimer.value === 0 ? "sleep_timer" : "sleep_timer_active"
410
+ }
411
+ sleepTimerDate={sleepTimerDate}
412
+ cancelSleepTimer={cancelSleepTimer}
413
+ onSkipLive={onSkipLive}
414
+ onCloseVideoModal={onCloseVideoModal}
415
+ maximiseVideoModal={maximiseVideoModal}
416
+ configuration={configuration}
417
+ dimensions={dimensions}
418
+ playNextData={playNextData}
419
+ title={title}
420
+ summary={summary}
421
+ defaultDimensions={defaultDimensions}
422
+ />
423
+ <View style={Styles.paddingHorizontal}>
424
+ {children}
425
+ <AnimationComponent
426
+ animationType={ComponentAnimationType.componentFade}
427
+ >
428
+ <PlayerDetails
429
+ configuration={configuration}
430
+ style={Styles.playerDetails}
431
+ entry={entry}
432
+ isTabletLandscape={isTabletLandscape}
433
+ isAudioPlayer={true}
434
+ />
435
+ </AnimationComponent>
436
+ </View>
437
+ </View>
438
+ </AnimatedScrollModal>
439
+ </AnimationComponent>
430
440
  </ContainerView>
431
441
  );
432
442
  }, [