@applicaster/quick-brick-player 14.0.0-rc.81 → 14.0.0-rc.83

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": "14.0.0-rc.81",
3
+ "version": "14.0.0-rc.83",
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": "14.0.0-rc.67",
38
+ "@applicaster/quick-brick-mobile-transport-controls": "14.0.0-rc.83",
39
39
  "@applicaster/quick-brick-tv-transport-controls": "14.0.0-rc.71",
40
- "@applicaster/zapp-react-native-tvos-app": "14.0.0-rc.81",
41
- "@applicaster/zapp-react-native-ui-components": "14.0.0-rc.81",
42
- "@applicaster/zapp-react-native-utils": "14.0.0-rc.81",
40
+ "@applicaster/zapp-react-native-tvos-app": "14.0.0-rc.83",
41
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-rc.83",
42
+ "@applicaster/zapp-react-native-utils": "14.0.0-rc.83",
43
43
  "query-string": "7.1.3",
44
44
  "shaka-player": "4.3.5",
45
45
  "typeface-montserrat": "^0.0.54",
@@ -61,6 +61,7 @@ type Props = {
61
61
  inline: boolean;
62
62
  docked: boolean;
63
63
  isModal: boolean;
64
+ pip: boolean;
64
65
  };
65
66
  playNextData: PlayNextData;
66
67
  isTabletPortrait?: boolean;
@@ -246,13 +247,28 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
246
247
  player?.seekTo(0);
247
248
  }, [player]);
248
249
 
250
+ const layoutStateMemo = React.useMemo(
251
+ () => ({
252
+ inline: layoutState.inline,
253
+ docked: layoutState.docked,
254
+ isModal: layoutState.isModal,
255
+ pip: layoutState.pip,
256
+ }),
257
+ [
258
+ layoutState.inline,
259
+ layoutState.docked,
260
+ layoutState.isModal,
261
+ layoutState.pip,
262
+ ]
263
+ );
264
+
249
265
  return (
250
266
  <SafeAreaView style={[style, Styles.playerContainer]} edges={edges}>
251
267
  <View style={Styles.playerContainer} onLayout={onLayout}>
252
268
  <Layout
253
269
  entry={entry}
254
270
  playerState={playerState}
255
- layoutState={layoutState}
271
+ layoutState={layoutStateMemo}
256
272
  value={value}
257
273
  onPlaybackButtonPress={onPlaybackButtonPress}
258
274
  onRewindButtonPress={onRewindButtonPress}
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, ViewStyle } from "react-native";
3
- import * as R from "ramda";
2
+ import { StyleSheet, View } from "react-native";
4
3
  import {
5
4
  useIsTablet,
6
5
  useZStore,
@@ -16,7 +15,6 @@ import {
16
15
 
17
16
  import { PlayNextData } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
18
17
 
19
- import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
20
18
  import { useSafeAreaInsets } from "react-native-safe-area-context";
21
19
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
22
20
  import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
@@ -27,6 +25,7 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
27
25
  import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
28
26
  import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
29
27
  import { usePlugins } from "@applicaster/zapp-react-native-redux";
28
+ import { partial } from "@applicaster/zapp-react-native-utils/utils";
30
29
 
31
30
  const bottomTabBarHeight = getTabBarHeight();
32
31
 
@@ -45,7 +44,6 @@ const styles = StyleSheet.create({
45
44
  flex: 1,
46
45
  flexDirection: "column",
47
46
  alignItems: "stretch",
48
- marginTop: PROGRESS_BAR_HEIGHT,
49
47
  },
50
48
  content: {
51
49
  flex: 1,
@@ -88,14 +86,12 @@ const styles = StyleSheet.create({
88
86
  buttons: {
89
87
  marginVertical: 10,
90
88
  },
89
+ liveMarginTop: { marginTop: 0 },
90
+ marginTop: { marginTop: PROGRESS_BAR_HEIGHT },
91
91
  });
92
92
 
93
- const playerDimensionsStyle = (
94
- minimisedHeight: number,
95
- addPadding: boolean
96
- ): ViewStyle => ({
97
- width: addPadding ? toNumberWithDefault(100, minimisedHeight) : 0,
98
- });
93
+ const getValue = (key: string, stylesObj: Record<string, any>) =>
94
+ stylesObj?.[key] ?? null;
99
95
 
100
96
  const controlButtons = (
101
97
  live: boolean,
@@ -161,7 +157,6 @@ export const DockedControls = (props: Props) => {
161
157
  onPlayerSeek = noop,
162
158
  playNextData,
163
159
  ImageComponent,
164
- isActiveGesture = true,
165
160
  aspectRatio,
166
161
  } = props;
167
162
 
@@ -179,11 +174,6 @@ export const DockedControls = (props: Props) => {
179
174
  const configuration = useZStore("playerConfiguration")();
180
175
  const playerState = usePlayerState("shared-player-wrapper-docked");
181
176
 
182
- const getValue = React.useCallback(
183
- (key: string, stylesObj: {}) => R.propOr(null, key, stylesObj),
184
- []
185
- );
186
-
187
177
  const value = React.useCallback(
188
178
  (key: string) => {
189
179
  const retVal = getValue(key, configuration);
@@ -202,7 +192,7 @@ export const DockedControls = (props: Props) => {
202
192
 
203
193
  return retVal;
204
194
  },
205
- [...Object.values(configuration), playerState.seekableDuration, getValue]
195
+ [...Object.values(configuration), playerState.seekableDuration]
206
196
  );
207
197
 
208
198
  const { title, summary } = useTitleSummaryOverlay(
@@ -219,15 +209,65 @@ export const DockedControls = (props: Props) => {
219
209
 
220
210
  const insets = useSafeAreaInsets();
221
211
 
212
+ const progressBarLayoutState = React.useMemo(
213
+ () => ({
214
+ inline: layoutState.inline,
215
+ docked: true,
216
+ isModal: layoutState.isModal,
217
+ pip: layoutState.pip,
218
+ }),
219
+ [layoutState.inline, layoutState.isModal, layoutState.pip]
220
+ );
221
+
222
+ const _controlButtons = React.useMemo(
223
+ () => partial(controlButtons, playerState.isLive && liveButton),
224
+ [playerState.isLive, liveButton]
225
+ );
226
+
227
+ const containerStyles = React.useMemo(
228
+ () => ({
229
+ height: minimisedHeight,
230
+ maxHeight: minimisedHeight,
231
+ }),
232
+ [minimisedHeight]
233
+ );
234
+
235
+ const imageComponentWrapperStyles = React.useMemo(
236
+ () => ({
237
+ aspectRatio: aspectRatio,
238
+ height: minimisedHeight,
239
+ }),
240
+ [aspectRatio, minimisedHeight]
241
+ );
242
+
243
+ const backgroundColorStyle = React.useMemo(
244
+ () => ({
245
+ backgroundColor: dockedBackgroundColor,
246
+ }),
247
+ [dockedBackgroundColor]
248
+ );
249
+
250
+ const bottomSpacerStyle = React.useMemo(() => {
251
+ const tabBarHeight = menuVisible ? bottomTabBarHeight : 0;
252
+ const safeAreaBottomInset = insets.bottom || 0;
253
+
254
+ return {
255
+ height: safeAreaBottomInset + tabBarHeight,
256
+ };
257
+ }, [menuVisible, insets.bottom]);
258
+
259
+ const contentInfoContent = React.useMemo(
260
+ () => ({ ...entry, title, summary }),
261
+ [title, summary, entry]
262
+ );
263
+
222
264
  return (
223
265
  <>
224
266
  <View
225
267
  style={[
226
268
  styles.container,
227
- {
228
- height: minimisedHeight,
229
- maxHeight: minimisedHeight,
230
- },
269
+ containerStyles,
270
+ playerState.isLive ? styles.liveMarginTop : styles.marginTop,
231
271
  ]}
232
272
  >
233
273
  {!playerState.isLive ? (
@@ -236,42 +276,23 @@ export const DockedControls = (props: Props) => {
236
276
  content={entry}
237
277
  value={value}
238
278
  visible
239
- layoutState={layoutState}
279
+ layoutState={progressBarLayoutState}
240
280
  onPlayerSeek={onPlayerSeek}
241
281
  playerState={playerState}
242
- startComponentsAnimation={noop}
243
282
  docked
244
283
  />
245
284
  ) : null}
246
285
 
247
286
  <View style={styles.content}>
248
287
  <View style={styles.touchableArea}>
249
- {isActiveGesture || layoutState.docked ? (
250
- <View
251
- style={{ aspectRatio: aspectRatio, height: minimisedHeight }}
252
- >
253
- {ImageComponent || null}
254
- </View>
255
- ) : (
256
- <View
257
- style={playerDimensionsStyle(
258
- minimisedHeight,
259
- isActiveGesture || layoutState.docked
260
- )}
261
- />
262
- )}
288
+ <View style={imageComponentWrapperStyles}>
289
+ {ImageComponent || null}
290
+ </View>
263
291
  <View
264
292
  testID="content-info"
265
- style={[
266
- styles.contentInfo,
267
- { backgroundColor: dockedBackgroundColor },
268
- ]}
293
+ style={[styles.contentInfo, backgroundColorStyle]}
269
294
  >
270
- <ContentInfo
271
- content={{ ...entry, title, summary }}
272
- value={value}
273
- docked
274
- />
295
+ <ContentInfo content={contentInfoContent} value={value} docked />
275
296
  </View>
276
297
  </View>
277
298
  <View
@@ -279,15 +300,13 @@ export const DockedControls = (props: Props) => {
279
300
  isTablet
280
301
  ? styles.controlsContainerForTablet
281
302
  : styles.controlsContainerForMobile,
282
- { backgroundColor: dockedBackgroundColor },
303
+ backgroundColorStyle,
283
304
  ]}
284
305
  >
285
306
  <Controls
286
307
  value={value}
287
308
  visible
288
- buttons={R.partial(controlButtons, [
289
- playerState.isLive && liveButton,
290
- ])}
309
+ buttons={_controlButtons}
291
310
  style={styles.playPauseButton}
292
311
  playNextData={playNextData}
293
312
  playerState={playerState}
@@ -302,12 +321,7 @@ export const DockedControls = (props: Props) => {
302
321
  </View>
303
322
  </View>
304
323
  </View>
305
- <View
306
- style={{
307
- height: insets.bottom + (menuVisible ? bottomTabBarHeight : 0),
308
- backgroundColor: dockedBackgroundColor,
309
- }}
310
- />
324
+ <View style={[bottomSpacerStyle, backgroundColorStyle]} />
311
325
  </>
312
326
  );
313
327
  };
@@ -151,12 +151,7 @@ export function MobileLayout({
151
151
  },
152
152
  ]}
153
153
  >
154
- <PlayerImage
155
- entry={entry}
156
- docked={false}
157
- imageWidth={imageSize}
158
- configuration={configuration}
159
- />
154
+ <PlayerImage entry={entry} configuration={configuration} />
160
155
  </View>
161
156
  {/* PlayerImage */}
162
157
 
@@ -4,7 +4,6 @@ import { LayoutChangeEvent, View } from "react-native";
4
4
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
5
5
  import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
6
6
 
7
- import { AnimatedImage } from "./AnimatedImage";
8
7
  import { FlexImage } from "./FlexImage";
9
8
 
10
9
  import { styles } from "./styles";
@@ -13,19 +12,12 @@ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/nu
13
12
  type Props = {
14
13
  entry: ZappEntry;
15
14
  configuration: QuickBrickPlayer.AudioPlayerProps["configuration"];
16
- docked: boolean;
17
- imageWidth?: Option<number>;
15
+ docked?: boolean;
18
16
  onLayoutImage?: (event: LayoutChangeEvent) => void;
19
17
  };
20
18
 
21
19
  export const PlayerImage = (props: Props) => {
22
- const {
23
- entry,
24
- docked,
25
- imageWidth,
26
- configuration,
27
- onLayoutImage = noop,
28
- } = props;
20
+ const { entry, docked = false, configuration, onLayoutImage = noop } = props;
29
21
 
30
22
  const isShadowEnabled = toBooleanWithDefaultTrue(
31
23
  configuration?.audio_player_artwork_shadow_enabled
@@ -43,19 +35,9 @@ export const PlayerImage = (props: Props) => {
43
35
  onLayout={onLayoutImage}
44
36
  style={[shouldShowShadow ? styles.shadow : undefined, { borderRadius }]}
45
37
  >
46
- {!imageWidth ? (
47
- <View style={[styles.defaultImageWrapperView, { borderRadius }]}>
48
- <FlexImage entry={entry} style={styles.backgroundImageContainer} />
49
- </View>
50
- ) : (
51
- // we have imageSize here and now we could animate resizing of this image
52
- <AnimatedImage
53
- entry={entry}
54
- style={[styles.backgroundImageContainer, { borderRadius }]}
55
- imageWidth={imageWidth}
56
- docked={docked}
57
- />
58
- )}
38
+ <View style={[styles.defaultImageWrapperView, { borderRadius }]}>
39
+ <FlexImage entry={entry} style={styles.backgroundImageContainer} />
40
+ </View>
59
41
  </View>
60
42
  </View>
61
43
  );
@@ -117,14 +117,11 @@ export function TabletLandscapeLayout({
117
117
  <View style={[styles.flex, styles.audioPlayerContainerHeightLimit]}>
118
118
  {/* PlayerImage non-docked */}
119
119
  <View style={[styles.flex, withDebug(styles.debugYellow)]}>
120
- {!docked ? (
121
- <PlayerImage
122
- docked={false}
123
- entry={entry}
124
- configuration={configuration}
125
- onLayoutImage={onLayoutImage}
126
- />
127
- ) : null}
120
+ <PlayerImage
121
+ entry={entry}
122
+ configuration={configuration}
123
+ onLayoutImage={onLayoutImage}
124
+ />
128
125
  </View>
129
126
  {/* PlayerImage */}
130
127
 
@@ -144,12 +144,7 @@ export function TabletPortraitLayout({
144
144
  ]}
145
145
  onLayout={onLayout}
146
146
  >
147
- <PlayerImage
148
- entry={entry}
149
- configuration={configuration}
150
- docked={docked}
151
- imageWidth={imageSize}
152
- />
147
+ <PlayerImage entry={entry} configuration={configuration} />
153
148
  </View>
154
149
 
155
150
  <View
@@ -1,10 +1,6 @@
1
1
  import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
2
- import {
3
- PlayerAnimationStateEnum,
4
- PlayerAnimationStateT,
5
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext";
2
+
6
3
  import { parseJsonIfNeeded } from "@applicaster/zapp-react-native-utils/functionUtils";
7
- import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
8
4
 
9
5
  export const NAMESPACE = "audio-player";
10
6
 
@@ -36,25 +32,3 @@ export const formatSpeed = (value: number) => {
36
32
  // Return the formatted string with "speed_" prefix
37
33
  return `speed_${formattedValue}`;
38
34
  };
39
-
40
- export const calculateBorderRadius = (
41
- docked: boolean,
42
- startComponentsAnimation: boolean,
43
- isActiveGesture: boolean,
44
- playerAnimationState: PlayerAnimationStateT,
45
- configuration: Record<string, any>
46
- ): number => {
47
- const shouldRemoveBorderRadius =
48
- (startComponentsAnimation &&
49
- isActiveGesture &&
50
- playerAnimationState !== PlayerAnimationStateEnum.maximize) ||
51
- docked;
52
-
53
- if (shouldRemoveBorderRadius) {
54
- return 0;
55
- }
56
-
57
- return toNumberWithDefaultZero(
58
- configuration.audio_player_artwork_border_radius
59
- );
60
- };
@@ -6,7 +6,7 @@ import { useStyles } from "./styles";
6
6
  import { useVideoModalState } from "./hooks";
7
7
  import { MODAL_COLLAPSE_RATIO, MODAL_RADIUS } from "./consts";
8
8
  import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
9
- import { getWindowHeight } from "./utils";
9
+ import { getScreenHeight, getWindowHeight } from "./utils";
10
10
 
11
11
  type AnimatedModalProps = {
12
12
  content?: ReactElement;
@@ -31,6 +31,7 @@ export function AnimatedModal({
31
31
 
32
32
  const WINDOW_HEIGHT = getWindowHeight();
33
33
  const heightAboveMinimised = WINDOW_HEIGHT - collapsedHeight;
34
+ const screenHeight = getScreenHeight();
34
35
 
35
36
  const MODAL_COLLAPSE_START = WINDOW_HEIGHT * MODAL_COLLAPSE_RATIO;
36
37
 
@@ -63,7 +64,7 @@ export function AnimatedModal({
63
64
  borderTopLeftRadius: borderTopRadiusAnimated,
64
65
  borderTopRightRadius: borderTopRadiusAnimated,
65
66
  transform: [{ translateY }],
66
- height: WINDOW_HEIGHT,
67
+ height: screenHeight,
67
68
  },
68
69
  ]}
69
70
  >
@@ -73,7 +74,7 @@ export function AnimatedModal({
73
74
  {
74
75
  borderTopLeftRadius: borderTopRadiusAnimated,
75
76
  borderTopRightRadius: borderTopRadiusAnimated,
76
- height: WINDOW_HEIGHT,
77
+ height: screenHeight,
77
78
  },
78
79
  ]}
79
80
  >
@@ -18,7 +18,7 @@ import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-component
18
18
  import { useSafeAreaInsets } from "react-native-safe-area-context";
19
19
  import { GestureAnimatedScrollView } from "./GestureAnimatedScrollView";
20
20
  import { PlayerDetailsWrapperHeightContext } from "./context";
21
- import { getWindowHeight, getWindowWidth } from "./utils";
21
+ import { getScreenHeight, getWindowHeight, getWindowWidth } from "./utils";
22
22
 
23
23
  const orientationStyles = StyleSheet.create({
24
24
  landscape: { flexDirection: "row" },
@@ -61,6 +61,7 @@ export function VideoPlayerModal({
61
61
 
62
62
  const WINDOW_WIDTH = useMemo(() => getWindowWidth(), []); // remember initial width, ignore rotation changes
63
63
  const height = useMemo(() => getWindowHeight(), []); // remember initial height, ignore rotation changes
64
+ const screenHeight = useMemo(() => getScreenHeight(), []); // remember initial height, ignore rotation changes
64
65
  const MODAL_COLLAPSE_START = height * MODAL_COLLAPSE_RATIO;
65
66
 
66
67
  let width = WINDOW_WIDTH;
@@ -115,7 +116,7 @@ export function VideoPlayerModal({
115
116
 
116
117
  const xPosition = !isFullScreenOrPIP
117
118
  ? translateY.interpolate({
118
- inputRange: [height * VIDEO_TRANSITION_THRESHOLD, heightAboveMinimised],
119
+ inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
119
120
  outputRange: [0, -(width - width * SCALE_FACTOR) / 2],
120
121
  extrapolate: "clamp",
121
122
  })
@@ -125,14 +126,16 @@ export function VideoPlayerModal({
125
126
 
126
127
  const yPosition = !isFullScreenOrPIP
127
128
  ? translateY.interpolate({
128
- inputRange: [
129
- height * VIDEO_TRANSITION_THRESHOLD,
130
- height - collapsedHeight,
131
- ],
129
+ inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
132
130
  outputRange: [
133
131
  0,
134
132
  isTablet && isTabletLandscape
135
- ? -((-PROGRESS_BAR_HEIGHT + height - vidHeight * SCALE_FACTOR) / 2)
133
+ ? -(
134
+ (-PROGRESS_BAR_HEIGHT +
135
+ screenHeight -
136
+ vidHeight * SCALE_FACTOR) /
137
+ 2
138
+ )
136
139
  : -(
137
140
  PROGRESS_BAR_HEIGHT +
138
141
  insets.top / 2 +
@@ -147,10 +150,7 @@ export function VideoPlayerModal({
147
150
 
148
151
  const scalePosition = !isFullScreenOrPIP
149
152
  ? translateY.interpolate({
150
- inputRange: [
151
- height * VIDEO_TRANSITION_THRESHOLD,
152
- height - collapsedHeight,
153
- ],
153
+ inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
154
154
  outputRange: [1, SCALE_FACTOR],
155
155
  extrapolate: "clamp",
156
156
  })
@@ -192,7 +192,7 @@ export function VideoPlayerModal({
192
192
  borderTopLeftRadius: borderTopRadiusAnimated,
193
193
  borderTopRightRadius: borderTopRadiusAnimated,
194
194
  transform: [{ translateY: isFullScreenOrPIP ? 0 : translateY }],
195
- height: height,
195
+ height: screenHeight,
196
196
  },
197
197
  ]}
198
198
  >
@@ -204,13 +204,16 @@ export function VideoPlayerModal({
204
204
  {
205
205
  borderTopLeftRadius: borderTopRadiusAnimated,
206
206
  borderTopRightRadius: borderTopRadiusAnimated,
207
- height: height,
207
+ height: screenHeight,
208
208
  },
209
209
  ]}
210
210
  >
211
211
  <Animated.View
212
212
  pointerEvents={!collapsed ? "auto" : "none"}
213
- style={[styles.modalContent, directionStyles(isTabletLandscape)]}
213
+ style={[
214
+ pip ? styles.modalContentPiP : styles.modalContent,
215
+ directionStyles(isTabletLandscape),
216
+ ]}
214
217
  >
215
218
  <Animated.View
216
219
  style={[
@@ -1,5 +1,8 @@
1
1
  import { useCallback, useEffect, useMemo, useRef } from "react";
2
- import { useSafeAreaInsets } from "react-native-safe-area-context";
2
+ import {
3
+ useSafeAreaFrame,
4
+ useSafeAreaInsets,
5
+ } from "react-native-safe-area-context";
3
6
  import { State } from "react-native-gesture-handler";
4
7
  import { Animated } from "react-native";
5
8
 
@@ -15,7 +18,7 @@ import {
15
18
  } from "../consts";
16
19
  import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
17
20
  import { usePlugins } from "@applicaster/zapp-react-native-redux";
18
- import { getWindowHeight } from "../utils";
21
+ import { isOldAndroidDevice } from "../utils";
19
22
 
20
23
  const bottomTabBarHeight = getTabBarHeight();
21
24
 
@@ -24,8 +27,6 @@ export const useVideoModalState = (
24
27
  ) => {
25
28
  const { minimised_height: minimisedHeight } = useConfiguration();
26
29
 
27
- const WINDOW_HEIGHT = getWindowHeight();
28
-
29
30
  const {
30
31
  maximiseVideoModal,
31
32
  minimiseVideoModal,
@@ -42,17 +43,16 @@ export const useVideoModalState = (
42
43
  videoModalState.visible &&
43
44
  videoModalState.mode === VideoModalMode.MINIMIZED;
44
45
 
45
- const { bottom } = useSafeAreaInsets();
46
-
47
- const initialBottomOffset = useRef(bottom).current;
46
+ const frame = useSafeAreaFrame();
47
+ const insets = useSafeAreaInsets();
48
48
 
49
49
  const collapsedHeight =
50
50
  minimisedHeight +
51
- initialBottomOffset +
52
51
  (menuVisible ? bottomTabBarHeight : 0) +
52
+ (isOldAndroidDevice ? 0 : insets.bottom) +
53
53
  PROGRESS_BAR_HEIGHT;
54
54
 
55
- const heightAboveMinimised = WINDOW_HEIGHT - collapsedHeight;
55
+ const heightAboveMinimised = frame.height - collapsedHeight;
56
56
 
57
57
  const translateY = translateYRef.current;
58
58
 
@@ -179,7 +179,12 @@ export const useVideoModalState = (
179
179
  });
180
180
  }
181
181
  }
182
- }, [videoModalState.visible, videoModalState.mode, collapsedHeight]);
182
+ }, [
183
+ videoModalState.visible,
184
+ videoModalState.mode,
185
+ collapsedHeight,
186
+ heightAboveMinimised,
187
+ ]);
183
188
 
184
189
  return useMemo(
185
190
  () => ({
@@ -75,6 +75,10 @@ export const useStyles = ({ height }: { height: number }) => {
75
75
  flex: 1,
76
76
  alignItems: "center",
77
77
  },
78
+ modalContentPiP: {
79
+ flex: 1,
80
+ alignItems: "flex-start",
81
+ },
78
82
  expandedContentContainer: {
79
83
  justifyContent: "flex-start",
80
84
  backgroundColor: BG_COLOR_DEFAULT_TRANSPARENT,
@@ -1,25 +1,25 @@
1
- import { StatusBar, Dimensions } from "react-native";
1
+ import { Dimensions } from "react-native";
2
2
 
3
3
  import {
4
4
  isAndroidPlatform,
5
5
  isAndroidVersionAtLeast,
6
6
  } from "@applicaster/zapp-react-native-utils/reactUtils";
7
- import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
8
7
 
9
8
  const MIN_SUPPORTED_ANDROID_API = 34;
10
9
 
11
- const isOldAndroidDevice =
12
- isAndroidPlatform() &&
13
- !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API) &&
14
- !isAndroidTablet();
10
+ export const isOldAndroidDevice =
11
+ isAndroidPlatform() && !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API);
15
12
 
16
13
  export const getWindowHeight = (): number => {
17
14
  const windowDimensions = Dimensions.get("window");
18
15
 
19
- return (
20
- windowDimensions.height +
21
- (isOldAndroidDevice ? (StatusBar.currentHeight ?? 0) : 0)
22
- );
16
+ return windowDimensions.height;
17
+ };
18
+
19
+ export const getScreenHeight = (): number => {
20
+ const screenDimensions = Dimensions.get("screen");
21
+
22
+ return screenDimensions.height;
23
23
  };
24
24
 
25
25
  export const getWindowWidth = (): number => {
@@ -83,7 +83,6 @@ type VideoPlayerProps = QuickBrickPlayer.PlayerProps & {
83
83
  updatePlayerState?: (state: string) => void;
84
84
  setNextVideoPreloadThresholdPercentage?: (percentage: number) => void;
85
85
  hideTransportControls?: boolean;
86
- startComponentsAnimation?: boolean;
87
86
  playableItem?: any;
88
87
  playerPluginIdentifier?: string;
89
88
  controller?: {
@@ -1047,10 +1046,7 @@ export default class VideoPlayer extends React.Component<
1047
1046
  : supportsNativeControls && !this.getPlayNextData();
1048
1047
 
1049
1048
  const shouldUseNativeControls =
1050
- controls &&
1051
- !this.props.startComponentsAnimation &&
1052
- !docked &&
1053
- !castAction?.state?.connected;
1049
+ controls && !docked && !castAction?.state?.connected;
1054
1050
 
1055
1051
  platformSpecificProps = {
1056
1052
  ...platformSpecificProps,
@@ -1134,7 +1130,8 @@ export default class VideoPlayer extends React.Component<
1134
1130
  const needsToRender =
1135
1131
  !hideTransportControls &&
1136
1132
  !needToShowPlayNextOverlay &&
1137
- this.props.mode !== "PIP";
1133
+ this.props.mode !== "PIP" &&
1134
+ !docked;
1138
1135
 
1139
1136
  const supportsNativeControls =
1140
1137
  !!this.props.controller?.supportsNativeControls?.();
@@ -1145,10 +1142,7 @@ export default class VideoPlayer extends React.Component<
1145
1142
  : supportsNativeControls && !this.getPlayNextData();
1146
1143
 
1147
1144
  const shouldUseNativeControls =
1148
- controls &&
1149
- !this.props.startComponentsAnimation &&
1150
- !docked &&
1151
- !castAction?.state?.connected;
1145
+ controls && !docked && !castAction?.state?.connected;
1152
1146
 
1153
1147
  if (shouldUseNativeControls) {
1154
1148
  return null;
@@ -1,82 +0,0 @@
1
- import React, { PropsWithChildren } from "react";
2
- import { Image, Animated, StyleSheet, ImageStyle } from "react-native";
3
-
4
- import {
5
- useModalAnimationContext,
6
- PlayerAnimationStateEnum,
7
- DURATION_TO_MINIMIZE,
8
- DURATION_TO_MAXIMIZE,
9
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
10
- import { PlayerAnimationStateT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext";
11
- import { useBackgroundImage } from "@applicaster/zapp-react-native-utils/audioPlayerUtils";
12
-
13
- import { useChangePlayerState } from "./hooks";
14
-
15
- const styles = StyleSheet.create({
16
- container: {
17
- // we have to specify flex:0 and dimensions to make animation work
18
- flex: 0,
19
- aspectRatio: 1,
20
- },
21
- });
22
-
23
- type Props = PropsWithChildren<{
24
- entry: ZappEntry;
25
- style?: ImageStyle | ImageStyle[];
26
- imageWidth: number;
27
- docked: boolean;
28
- }>;
29
-
30
- export const AnimatedImage = ({ entry, style, imageWidth, docked }: Props) => {
31
- const heightAnim = React.useRef(new Animated.Value(imageWidth)).current;
32
-
33
- const backgroundImageSource = useBackgroundImage(entry);
34
-
35
- const { minimisedHeight } = useModalAnimationContext();
36
-
37
- const changePlayerState$ = useChangePlayerState({ docked });
38
-
39
- React.useEffect(() => {
40
- const subscription = changePlayerState$.subscribe({
41
- next: (nextPlayerState: PlayerAnimationStateT) => {
42
- if (nextPlayerState === PlayerAnimationStateEnum.minimize) {
43
- Animated.timing(heightAnim, {
44
- toValue: minimisedHeight,
45
- duration: DURATION_TO_MINIMIZE,
46
- useNativeDriver: false, // width/height can't use native driver
47
- }).start();
48
- }
49
-
50
- if (nextPlayerState === PlayerAnimationStateEnum.maximize) {
51
- Animated.timing(heightAnim, {
52
- toValue: imageWidth,
53
- duration: DURATION_TO_MAXIMIZE,
54
- useNativeDriver: false, // width/height can't use native driver
55
- }).start();
56
- }
57
-
58
- if (nextPlayerState === PlayerAnimationStateEnum.appear_as_docked) {
59
- // minimize image immediatly
60
- heightAnim.setValue(minimisedHeight);
61
- }
62
- },
63
- });
64
-
65
- return () => {
66
- subscription.unsubscribe();
67
- };
68
- }, [changePlayerState$, minimisedHeight, imageWidth]);
69
-
70
- return (
71
- <Animated.View
72
- style={[
73
- styles.container,
74
- {
75
- width: heightAnim,
76
- },
77
- ]}
78
- >
79
- <Image resizeMode="cover" style={style} source={backgroundImageSource} />
80
- </Animated.View>
81
- );
82
- };
@@ -1 +0,0 @@
1
- export { useChangePlayerState } from "./useChangePlayerState";
@@ -1,99 +0,0 @@
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
- };