@applicaster/quick-brick-player 13.0.0-rc.120 → 13.0.0-rc.122
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 +4 -4
- package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +24 -7
- package/src/Player/AudioLayer/Layout/PlayerImage/AnimatedImage.tsx +35 -18
- package/src/Player/AudioLayer/Layout/PlayerImage/hooks/index.ts +1 -0
- package/src/Player/AudioLayer/Layout/PlayerImage/hooks/useChangePlayerState.ts +79 -0
- package/src/Player/AudioLayer/Layout/PlayerImage/index.tsx +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "13.0.0-rc.
|
|
3
|
+
"version": "13.0.0-rc.122",
|
|
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.
|
|
41
|
-
"@applicaster/zapp-react-native-ui-components": "13.0.0-rc.
|
|
42
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-rc.
|
|
40
|
+
"@applicaster/zapp-react-native-tvos-app": "13.0.0-rc.122",
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components": "13.0.0-rc.122",
|
|
42
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-rc.122",
|
|
43
43
|
"query-string": "7.1.3",
|
|
44
44
|
"react-native-web-linear-gradient": "1.1.2",
|
|
45
45
|
"shaka-player": "4.3.5",
|
|
@@ -24,6 +24,10 @@ import {
|
|
|
24
24
|
useModalAnimationContext,
|
|
25
25
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
26
26
|
import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
27
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
28
|
+
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
29
|
+
|
|
30
|
+
const bottomTabBarHeight = getTabBarHeight();
|
|
27
31
|
|
|
28
32
|
type Props = {
|
|
29
33
|
entry: ZappEntry;
|
|
@@ -88,10 +92,6 @@ const styles = StyleSheet.create({
|
|
|
88
92
|
},
|
|
89
93
|
});
|
|
90
94
|
|
|
91
|
-
const backgroundColorStyle = (value: GetValue): ViewStyle => ({
|
|
92
|
-
backgroundColor: value("docked_player_background_color"),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
95
|
const playerDimensionsStyle = (
|
|
96
96
|
minimisedHeight: number,
|
|
97
97
|
addPadding: boolean
|
|
@@ -208,6 +208,10 @@ export const DockedControls = (props: Props) => {
|
|
|
208
208
|
[]
|
|
209
209
|
);
|
|
210
210
|
|
|
211
|
+
const dockedBackgroundColor = value("docked_player_background_color");
|
|
212
|
+
|
|
213
|
+
const insets = useSafeAreaInsets();
|
|
214
|
+
|
|
211
215
|
if (!layoutState.docked && !startComponentsAnimation) return null;
|
|
212
216
|
|
|
213
217
|
return (
|
|
@@ -219,7 +223,9 @@ export const DockedControls = (props: Props) => {
|
|
|
219
223
|
isActiveGesture || layoutState.docked,
|
|
220
224
|
progressBarHeight
|
|
221
225
|
),
|
|
222
|
-
{
|
|
226
|
+
{
|
|
227
|
+
height: minimisedHeight + bottomTabBarHeight + insets.bottom,
|
|
228
|
+
},
|
|
223
229
|
]}
|
|
224
230
|
>
|
|
225
231
|
{!playerState.isLive &&
|
|
@@ -261,7 +267,12 @@ export const DockedControls = (props: Props) => {
|
|
|
261
267
|
)}
|
|
262
268
|
/>
|
|
263
269
|
)}
|
|
264
|
-
<View
|
|
270
|
+
<View
|
|
271
|
+
style={[
|
|
272
|
+
styles.contentInfo,
|
|
273
|
+
{ backgroundColor: dockedBackgroundColor },
|
|
274
|
+
]}
|
|
275
|
+
>
|
|
265
276
|
<ContentInfo
|
|
266
277
|
content={{ ...entry, title, summary }}
|
|
267
278
|
value={value}
|
|
@@ -275,7 +286,7 @@ export const DockedControls = (props: Props) => {
|
|
|
275
286
|
isTablet
|
|
276
287
|
? styles.controlsContainerForTablet
|
|
277
288
|
: styles.controlsContainerForMobile,
|
|
278
|
-
|
|
289
|
+
{ backgroundColor: dockedBackgroundColor },
|
|
279
290
|
]}
|
|
280
291
|
>
|
|
281
292
|
<Controls
|
|
@@ -297,6 +308,12 @@ export const DockedControls = (props: Props) => {
|
|
|
297
308
|
/>
|
|
298
309
|
</View>
|
|
299
310
|
</View>
|
|
311
|
+
<View
|
|
312
|
+
style={{
|
|
313
|
+
height: insets.bottom + bottomTabBarHeight,
|
|
314
|
+
backgroundColor: dockedBackgroundColor,
|
|
315
|
+
}}
|
|
316
|
+
/>
|
|
300
317
|
</AnimationComponent>
|
|
301
318
|
);
|
|
302
319
|
};
|
|
@@ -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 {
|
|
38
|
+
const { minimisedHeight } = useModalAnimationContext();
|
|
39
|
+
|
|
40
|
+
const changePlayerState$ = useChangePlayerState({ docked });
|
|
35
41
|
|
|
36
42
|
React.useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
61
|
+
if (nextPlayerState === PlayerAnimationStateEnum.appear_as_docked) {
|
|
62
|
+
// minimize image immediatly
|
|
63
|
+
heightAnim.setValue(minimisedHeight);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
46
67
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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,79 @@
|
|
|
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 emitMaximazed = (): 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
|
+
emitMaximazed,
|
|
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.emitMaximazed();
|
|
65
|
+
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
docked &&
|
|
71
|
+
isNil(previousPlayerAnimationState) &&
|
|
72
|
+
isNil(playerAnimationState)
|
|
73
|
+
) {
|
|
74
|
+
changePlayerStateRef.current.emitAppearInDocked();
|
|
75
|
+
}
|
|
76
|
+
}, [previousPlayerAnimationState, playerAnimationState, docked]);
|
|
77
|
+
|
|
78
|
+
return changePlayerStateRef.current.changePlayerState$;
|
|
79
|
+
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ComponentAnimationType,
|
|
6
6
|
useModalAnimationContext,
|
|
7
7
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
8
|
+
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
8
9
|
|
|
9
10
|
import { AnimatedImage } from "./AnimatedImage";
|
|
10
11
|
import { FlexImage } from "./FlexImage";
|
|
@@ -29,7 +30,7 @@ type Props = {
|
|
|
29
30
|
docked: boolean;
|
|
30
31
|
imageWidth?: Option<number>;
|
|
31
32
|
verticalOffset: number;
|
|
32
|
-
onLayoutImage
|
|
33
|
+
onLayoutImage?: (event: LayoutChangeEvent) => void;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export const PlayerImage = (props: Props) => {
|
|
@@ -40,7 +41,7 @@ export const PlayerImage = (props: Props) => {
|
|
|
40
41
|
verticalOffset,
|
|
41
42
|
imageWidth,
|
|
42
43
|
configuration,
|
|
43
|
-
onLayoutImage,
|
|
44
|
+
onLayoutImage = noop,
|
|
44
45
|
} = props;
|
|
45
46
|
|
|
46
47
|
const {
|
|
@@ -99,6 +100,7 @@ export const PlayerImage = (props: Props) => {
|
|
|
99
100
|
entry={entry}
|
|
100
101
|
style={[styles.backgroundImageContainer, { borderRadius }]}
|
|
101
102
|
imageWidth={imageWidth}
|
|
103
|
+
docked={docked}
|
|
102
104
|
/>
|
|
103
105
|
)}
|
|
104
106
|
</View>
|