@applicaster/quick-brick-player 13.0.0-rc.121 → 13.0.0-rc.123

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-rc.121",
3
+ "version": "13.0.0-rc.123",
4
4
  "description": "Quick Brick Player",
5
5
  "main": "./src/index.ts",
6
6
  "types": "index.d.ts",
@@ -37,9 +37,9 @@
37
37
  "dependencies": {
38
38
  "@applicaster/quick-brick-mobile-transport-controls": "13.0.0-rc.120",
39
39
  "@applicaster/quick-brick-tv-transport-controls": "13.0.0-rc.56",
40
- "@applicaster/zapp-react-native-tvos-app": "13.0.0-rc.121",
41
- "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.121",
42
- "@applicaster/zapp-react-native-utils": "13.0.0-rc.121",
40
+ "@applicaster/zapp-react-native-tvos-app": "13.0.0-rc.123",
41
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.123",
42
+ "@applicaster/zapp-react-native-utils": "13.0.0-rc.123",
43
43
  "query-string": "7.1.3",
44
44
  "react-native-web-linear-gradient": "1.1.2",
45
45
  "shaka-player": "4.3.5",
@@ -8,6 +8,9 @@ import {
8
8
  DURATION_TO_MINIMIZE,
9
9
  DURATION_TO_MAXIMIZE,
10
10
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
11
+ import { PlayerAnimationStateT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext";
12
+
13
+ import { useChangePlayerState } from "./hooks";
11
14
 
12
15
  const styles = StyleSheet.create({
13
16
  container: {
@@ -21,9 +24,10 @@ type Props = PropsWithChildren<{
21
24
  entry: ZappEntry;
22
25
  style?: ImageStyle | ImageStyle[];
23
26
  imageWidth: number;
27
+ docked: boolean;
24
28
  }>;
25
29
 
26
- export const AnimatedImage = ({ entry, style, imageWidth }: Props) => {
30
+ export const AnimatedImage = ({ entry, style, imageWidth, docked }: Props) => {
27
31
  const heightAnim = React.useRef(new Animated.Value(imageWidth)).current;
28
32
 
29
33
  const source = React.useMemo(
@@ -31,27 +35,40 @@ export const AnimatedImage = ({ entry, style, imageWidth }: Props) => {
31
35
  [entry]
32
36
  );
33
37
 
34
- const { playerAnimationState, minimisedHeight } = useModalAnimationContext();
38
+ const { minimisedHeight } = useModalAnimationContext();
39
+
40
+ const changePlayerState$ = useChangePlayerState({ docked });
35
41
 
36
42
  React.useEffect(() => {
37
- if (playerAnimationState === PlayerAnimationStateEnum.minimize) {
38
- Animated.timing(heightAnim, {
39
- toValue: minimisedHeight,
40
- duration: DURATION_TO_MINIMIZE,
41
- useNativeDriver: false, // width/height can't use native driver
42
- }).start();
43
+ const subscription = changePlayerState$.subscribe({
44
+ next: (nextPlayerState: PlayerAnimationStateT) => {
45
+ if (nextPlayerState === PlayerAnimationStateEnum.minimize) {
46
+ Animated.timing(heightAnim, {
47
+ toValue: minimisedHeight,
48
+ duration: DURATION_TO_MINIMIZE,
49
+ useNativeDriver: false, // width/height can't use native driver
50
+ }).start();
51
+ }
52
+
53
+ if (nextPlayerState === PlayerAnimationStateEnum.maximize) {
54
+ Animated.timing(heightAnim, {
55
+ toValue: imageWidth,
56
+ duration: DURATION_TO_MAXIMIZE,
57
+ useNativeDriver: false, // width/height can't use native driver
58
+ }).start();
59
+ }
43
60
 
44
- return;
45
- }
61
+ if (nextPlayerState === PlayerAnimationStateEnum.appear_as_docked) {
62
+ // minimize image immediatly
63
+ heightAnim.setValue(minimisedHeight);
64
+ }
65
+ },
66
+ });
46
67
 
47
- if (playerAnimationState === PlayerAnimationStateEnum.maximize) {
48
- Animated.timing(heightAnim, {
49
- toValue: imageWidth,
50
- duration: DURATION_TO_MAXIMIZE,
51
- useNativeDriver: false, // width/height can't use native driver
52
- }).start();
53
- }
54
- }, [playerAnimationState, imageWidth]);
68
+ return () => {
69
+ subscription.unsubscribe();
70
+ };
71
+ }, [changePlayerState$, minimisedHeight, imageWidth]);
55
72
 
56
73
  if (!source) return null;
57
74
 
@@ -0,0 +1 @@
1
+ export { useChangePlayerState } from "./useChangePlayerState";
@@ -0,0 +1,99 @@
1
+ import * as React from "react";
2
+ import { Subject, Observable } from "rxjs";
3
+
4
+ import { distinctUntilChanged } from "rxjs/operators";
5
+ import { isNil } from "@applicaster/zapp-react-native-utils/utils";
6
+ import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
7
+ import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
8
+ import {
9
+ useModalAnimationContext,
10
+ PlayerAnimationStateEnum,
11
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
12
+ import { PlayerAnimationStateT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext";
13
+
14
+ const builder = () => {
15
+ const changePlayerState$ = new Subject<PlayerAnimationStateT>();
16
+
17
+ const emitMaximized = (): void => {
18
+ changePlayerState$.next(PlayerAnimationStateEnum.maximize);
19
+ };
20
+
21
+ const emitMinimized = (): void => {
22
+ changePlayerState$.next(PlayerAnimationStateEnum.minimize);
23
+ };
24
+
25
+ const emitAppearInDocked = (): void => {
26
+ // if audio_player was presented in docked mode
27
+ changePlayerState$.next(PlayerAnimationStateEnum.appear_as_docked);
28
+ };
29
+
30
+ return {
31
+ emitMaximized,
32
+ emitMinimized,
33
+ emitAppearInDocked,
34
+ changePlayerState$: changePlayerState$.pipe(distinctUntilChanged()),
35
+ };
36
+ };
37
+
38
+ export const useChangePlayerState = ({
39
+ docked,
40
+ }): Observable<PlayerAnimationStateT> => {
41
+ const changePlayerStateRef =
42
+ useRefWithInitialValue<ReturnType<typeof builder>>(builder);
43
+
44
+ const { playerAnimationState } = useModalAnimationContext();
45
+
46
+ const previousPlayerAnimationState = usePrevious(playerAnimationState);
47
+
48
+ React.useEffect(() => {
49
+ if (
50
+ !docked &&
51
+ isNil(previousPlayerAnimationState) &&
52
+ playerAnimationState === PlayerAnimationStateEnum.minimize
53
+ ) {
54
+ changePlayerStateRef.current.emitMinimized();
55
+
56
+ return;
57
+ }
58
+
59
+ if (
60
+ !docked &&
61
+ isNil(previousPlayerAnimationState) &&
62
+ playerAnimationState === PlayerAnimationStateEnum.maximize
63
+ ) {
64
+ changePlayerStateRef.current.emitMaximized();
65
+
66
+ return;
67
+ }
68
+
69
+ if (
70
+ !docked &&
71
+ previousPlayerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
72
+ playerAnimationState === PlayerAnimationStateEnum.maximize
73
+ ) {
74
+ changePlayerStateRef.current.emitMaximized();
75
+
76
+ return;
77
+ }
78
+
79
+ if (
80
+ !docked &&
81
+ previousPlayerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
82
+ playerAnimationState === PlayerAnimationStateEnum.minimize
83
+ ) {
84
+ changePlayerStateRef.current.emitMinimized();
85
+
86
+ return;
87
+ }
88
+
89
+ if (
90
+ docked &&
91
+ isNil(previousPlayerAnimationState) &&
92
+ isNil(playerAnimationState)
93
+ ) {
94
+ changePlayerStateRef.current.emitAppearInDocked();
95
+ }
96
+ }, [previousPlayerAnimationState, playerAnimationState, docked]);
97
+
98
+ return changePlayerStateRef.current.changePlayerState$;
99
+ };
@@ -1,10 +1,13 @@
1
1
  import * as React from "react";
2
+ import { LayoutChangeEvent, View } from "react-native";
2
3
 
3
4
  import {
4
5
  AnimationComponent,
5
6
  ComponentAnimationType,
6
7
  useModalAnimationContext,
7
8
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
9
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
10
+ import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
8
11
 
9
12
  import { AnimatedImage } from "./AnimatedImage";
10
13
  import { FlexImage } from "./FlexImage";
@@ -12,7 +15,6 @@ import { FlexImage } from "./FlexImage";
12
15
  import { styles } from "./styles";
13
16
  import { calculateBorderRadius } from "../../utils";
14
17
  import { PlayNextData } from "../types";
15
- import { LayoutChangeEvent, View } from "react-native";
16
18
 
17
19
  type Props = {
18
20
  entry: ZappEntry;
@@ -29,7 +31,7 @@ type Props = {
29
31
  docked: boolean;
30
32
  imageWidth?: Option<number>;
31
33
  verticalOffset: number;
32
- onLayoutImage: (event: LayoutChangeEvent) => void;
34
+ onLayoutImage?: (event: LayoutChangeEvent) => void;
33
35
  };
34
36
 
35
37
  export const PlayerImage = (props: Props) => {
@@ -40,7 +42,7 @@ export const PlayerImage = (props: Props) => {
40
42
  verticalOffset,
41
43
  imageWidth,
42
44
  configuration,
43
- onLayoutImage,
45
+ onLayoutImage = noop,
44
46
  } = props;
45
47
 
46
48
  const {
@@ -50,8 +52,9 @@ export const PlayerImage = (props: Props) => {
50
52
  minimisedHeight,
51
53
  } = useModalAnimationContext();
52
54
 
53
- const isShadowEnabled =
54
- configuration?.audio_player_artwork_shadow_enabled ?? true;
55
+ const isShadowEnabled = toBooleanWithDefaultTrue(
56
+ configuration?.audio_player_artwork_shadow_enabled
57
+ );
55
58
 
56
59
  const shouldShowShadow = !docked && isShadowEnabled;
57
60
 
@@ -99,6 +102,7 @@ export const PlayerImage = (props: Props) => {
99
102
  entry={entry}
100
103
  style={[styles.backgroundImageContainer, { borderRadius }]}
101
104
  imageWidth={imageWidth}
105
+ docked={docked}
102
106
  />
103
107
  )}
104
108
  </View>