@applicaster/quick-brick-player 15.0.0-alpha.6141436051 → 15.0.0-alpha.6835718972
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 +5 -5
- package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +4 -3
- package/src/Player/PlayerModal/PlayerModal.tsx +4 -5
- package/src/Player/PlayerModal/VideoPlayerModal.tsx +98 -91
- package/src/Player/PlayerModal/hooks/index.ts +15 -10
- package/src/Player/PlayerModal/styles.ts +5 -0
- package/src/Player/PlayerModal/utils/index.ts +73 -10
- package/src/Player/index.tsx +23 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.6835718972",
|
|
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": "15.0.0-
|
|
38
|
+
"@applicaster/quick-brick-mobile-transport-controls": "15.0.0-rc.27",
|
|
39
39
|
"@applicaster/quick-brick-tv-transport-controls": "15.0.0-rc.15",
|
|
40
|
-
"@applicaster/zapp-react-native-tvos-app": "15.0.0-alpha.
|
|
41
|
-
"@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.
|
|
42
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
40
|
+
"@applicaster/zapp-react-native-tvos-app": "15.0.0-alpha.6835718972",
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.6835718972",
|
|
42
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.6835718972",
|
|
43
43
|
"query-string": "7.1.3",
|
|
44
44
|
"shaka-player": "4.3.5",
|
|
45
45
|
"typeface-montserrat": "^0.0.54",
|
|
@@ -90,7 +90,8 @@ const styles = StyleSheet.create({
|
|
|
90
90
|
marginTop: { marginTop: PROGRESS_BAR_HEIGHT },
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
const getValue = (key: string, stylesObj:
|
|
93
|
+
const getValue = (key: string, stylesObj: Record<string, any>) =>
|
|
94
|
+
stylesObj?.[key] ?? null;
|
|
94
95
|
|
|
95
96
|
const controlButtons = (
|
|
96
97
|
live: boolean,
|
|
@@ -208,7 +209,7 @@ export const DockedControls = (props: Props) => {
|
|
|
208
209
|
|
|
209
210
|
const insets = useSafeAreaInsets();
|
|
210
211
|
|
|
211
|
-
const
|
|
212
|
+
const progressBarLayoutState = React.useMemo(
|
|
212
213
|
() => ({
|
|
213
214
|
inline: layoutState.inline,
|
|
214
215
|
docked: true,
|
|
@@ -275,7 +276,7 @@ export const DockedControls = (props: Props) => {
|
|
|
275
276
|
content={entry}
|
|
276
277
|
value={value}
|
|
277
278
|
visible
|
|
278
|
-
layoutState={
|
|
279
|
+
layoutState={progressBarLayoutState}
|
|
279
280
|
onPlayerSeek={onPlayerSeek}
|
|
280
281
|
playerState={playerState}
|
|
281
282
|
docked
|
|
@@ -29,10 +29,10 @@ export function AnimatedModal({
|
|
|
29
29
|
|
|
30
30
|
const styles = useStyles({ height: collapsedHeight, type: "audio" });
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
const heightAboveMinimised =
|
|
32
|
+
const height = getWindowHeight();
|
|
33
|
+
const heightAboveMinimised = height - collapsedHeight;
|
|
34
34
|
|
|
35
|
-
const MODAL_COLLAPSE_START =
|
|
35
|
+
const MODAL_COLLAPSE_START = height * MODAL_COLLAPSE_RATIO;
|
|
36
36
|
|
|
37
37
|
// Interpolated opacities for smooth cross-fade
|
|
38
38
|
const collapsedOpacity = translateY.interpolate({
|
|
@@ -63,7 +63,7 @@ export function AnimatedModal({
|
|
|
63
63
|
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
64
64
|
borderTopRightRadius: borderTopRadiusAnimated,
|
|
65
65
|
transform: [{ translateY }],
|
|
66
|
-
height:
|
|
66
|
+
height: height,
|
|
67
67
|
},
|
|
68
68
|
]}
|
|
69
69
|
>
|
|
@@ -73,7 +73,6 @@ export function AnimatedModal({
|
|
|
73
73
|
{
|
|
74
74
|
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
75
75
|
borderTopRightRadius: borderTopRadiusAnimated,
|
|
76
|
-
height: WINDOW_HEIGHT,
|
|
77
76
|
},
|
|
78
77
|
]}
|
|
79
78
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement, useMemo, useRef } from "react";
|
|
2
2
|
|
|
3
|
-
import { Animated, Pressable
|
|
3
|
+
import { Animated, Pressable } from "react-native";
|
|
4
4
|
import { PanGestureHandler } from "react-native-gesture-handler";
|
|
5
5
|
import { useStyles } from "./styles";
|
|
6
6
|
import { useConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
|
|
@@ -12,22 +12,23 @@ import {
|
|
|
12
12
|
VIDEO_TRANSITION_THRESHOLD,
|
|
13
13
|
} from "./consts";
|
|
14
14
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
15
|
-
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
16
15
|
import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext";
|
|
17
16
|
import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
|
|
18
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
SafeAreaView,
|
|
19
|
+
useSafeAreaFrame,
|
|
20
|
+
useSafeAreaInsets,
|
|
21
|
+
} from "react-native-safe-area-context";
|
|
19
22
|
import { GestureAnimatedScrollView } from "./GestureAnimatedScrollView";
|
|
20
23
|
import { PlayerDetailsWrapperHeightContext } from "./context";
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return isLandscape ? orientationStyles.landscape : orientationStyles.portrait;
|
|
30
|
-
};
|
|
24
|
+
import {
|
|
25
|
+
getInsetsOffset,
|
|
26
|
+
getWindowHeight,
|
|
27
|
+
getWindowWidth,
|
|
28
|
+
directionStyles,
|
|
29
|
+
getScaledPos,
|
|
30
|
+
getExtraContentPadding,
|
|
31
|
+
} from "./utils";
|
|
31
32
|
|
|
32
33
|
type AnimatedModalProps = {
|
|
33
34
|
pip?: boolean;
|
|
@@ -59,16 +60,19 @@ export function VideoPlayerModal({
|
|
|
59
60
|
const enabled = !!modal && !fullscreen;
|
|
60
61
|
const isTablet = useIsTablet();
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
// remember initial width, ignore rotation changes
|
|
64
|
+
const width = useMemo(
|
|
65
|
+
() =>
|
|
66
|
+
isTablet && !isTabletPortrait
|
|
67
|
+
? style.tabletLandscapeWidth
|
|
68
|
+
: getWindowWidth(),
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
|
|
63
73
|
const height = useMemo(() => getWindowHeight(), []); // remember initial height, ignore rotation changes
|
|
64
74
|
const MODAL_COLLAPSE_START = height * MODAL_COLLAPSE_RATIO;
|
|
65
75
|
|
|
66
|
-
let width = WINDOW_WIDTH;
|
|
67
|
-
|
|
68
|
-
if (isTablet && !isTabletPortrait) {
|
|
69
|
-
width = style?.tabletLandscapeWidth || width;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
76
|
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
73
77
|
const scrollViewRef = useRef<typeof Animated.ScrollView | null>(null);
|
|
74
78
|
|
|
@@ -84,9 +88,9 @@ export function VideoPlayerModal({
|
|
|
84
88
|
expand,
|
|
85
89
|
} = useVideoModalState(modal ? translateYRef : dummyRef);
|
|
86
90
|
|
|
87
|
-
const
|
|
91
|
+
const frame = useSafeAreaFrame();
|
|
88
92
|
|
|
89
|
-
const
|
|
93
|
+
const heightAboveMinimised = height - collapsedHeight;
|
|
90
94
|
|
|
91
95
|
const styles = useStyles({ height: collapsedHeight });
|
|
92
96
|
|
|
@@ -113,6 +117,7 @@ export function VideoPlayerModal({
|
|
|
113
117
|
})
|
|
114
118
|
: new Animated.Value(1);
|
|
115
119
|
|
|
120
|
+
// animated position for video content during modal transition
|
|
116
121
|
const xPosition = !isFullScreenOrPIP
|
|
117
122
|
? translateY.interpolate({
|
|
118
123
|
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
|
|
@@ -123,25 +128,23 @@ export function VideoPlayerModal({
|
|
|
123
128
|
|
|
124
129
|
const vidHeight = width / aspectRatio;
|
|
125
130
|
|
|
131
|
+
// animated position for video content during modal transition
|
|
126
132
|
const yPosition = !isFullScreenOrPIP
|
|
127
133
|
? translateY.interpolate({
|
|
128
134
|
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
|
|
129
135
|
outputRange: [
|
|
130
136
|
0,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(WINDOW_WIDTH / aspectRatio -
|
|
137
|
-
(WINDOW_WIDTH / aspectRatio) * SCALE_FACTOR) /
|
|
138
|
-
2
|
|
139
|
-
),
|
|
137
|
+
-(
|
|
138
|
+
PROGRESS_BAR_HEIGHT +
|
|
139
|
+
getInsetsOffset(insets, isTabletPortrait) +
|
|
140
|
+
getScaledPos(height, vidHeight, minimisedHeight, isTabletPortrait)
|
|
141
|
+
),
|
|
140
142
|
],
|
|
141
143
|
extrapolate: "clamp",
|
|
142
144
|
})
|
|
143
145
|
: new Animated.Value(0);
|
|
144
146
|
|
|
147
|
+
// animated position for video content during modal transition
|
|
145
148
|
const scalePosition = !isFullScreenOrPIP
|
|
146
149
|
? translateY.interpolate({
|
|
147
150
|
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
|
|
@@ -152,7 +155,7 @@ export function VideoPlayerModal({
|
|
|
152
155
|
|
|
153
156
|
const borderTopRadiusAnimated = !isFullScreenOrPIP
|
|
154
157
|
? translateY.interpolate({
|
|
155
|
-
inputRange: [0,
|
|
158
|
+
inputRange: [0, heightAboveMinimised],
|
|
156
159
|
outputRange: [MODAL_RADIUS, 0],
|
|
157
160
|
extrapolate: "clamp",
|
|
158
161
|
})
|
|
@@ -178,88 +181,92 @@ export function VideoPlayerModal({
|
|
|
178
181
|
waitFor={scrollViewRef}
|
|
179
182
|
{...gestureHandlerProps}
|
|
180
183
|
>
|
|
181
|
-
<
|
|
182
|
-
pointerEvents={"auto"}
|
|
183
|
-
style={[
|
|
184
|
-
styles.modalWrapper,
|
|
185
|
-
{
|
|
186
|
-
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
187
|
-
borderTopRightRadius: borderTopRadiusAnimated,
|
|
188
|
-
transform: [{ translateY: isFullScreenOrPIP ? 0 : translateY }],
|
|
189
|
-
height: height,
|
|
190
|
-
},
|
|
191
|
-
]}
|
|
192
|
-
>
|
|
184
|
+
<SafeAreaView pointerEvents="box-none" edges={["bottom"]}>
|
|
193
185
|
<Animated.View
|
|
194
186
|
pointerEvents={"auto"}
|
|
195
187
|
style={[
|
|
196
|
-
styles.
|
|
197
|
-
collapsed ? styles.collapsedModalBg : null,
|
|
188
|
+
styles.modalWrapper,
|
|
198
189
|
{
|
|
199
190
|
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
200
191
|
borderTopRightRadius: borderTopRadiusAnimated,
|
|
201
|
-
|
|
192
|
+
transform: [{ translateY: isFullScreenOrPIP ? 0 : translateY }],
|
|
193
|
+
height: frame.height,
|
|
202
194
|
},
|
|
203
195
|
]}
|
|
204
196
|
>
|
|
205
197
|
<Animated.View
|
|
206
|
-
pointerEvents={
|
|
207
|
-
style={[
|
|
198
|
+
pointerEvents={"auto"}
|
|
199
|
+
style={[
|
|
200
|
+
styles.modal,
|
|
201
|
+
collapsed ? styles.collapsedModalBg : null,
|
|
202
|
+
{
|
|
203
|
+
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
204
|
+
borderTopRightRadius: borderTopRadiusAnimated,
|
|
205
|
+
},
|
|
206
|
+
]}
|
|
208
207
|
>
|
|
209
208
|
<Animated.View
|
|
209
|
+
pointerEvents={!collapsed ? "auto" : "none"}
|
|
210
210
|
style={[
|
|
211
|
-
styles.
|
|
212
|
-
|
|
213
|
-
transform: [
|
|
214
|
-
{ translateX: xPosition },
|
|
215
|
-
{ translateY: yPosition },
|
|
216
|
-
{ scale: scalePosition },
|
|
217
|
-
],
|
|
218
|
-
},
|
|
211
|
+
pip ? styles.modalContentPiP : styles.modalContent,
|
|
212
|
+
directionStyles(isTabletPortrait),
|
|
219
213
|
]}
|
|
220
214
|
>
|
|
221
|
-
|
|
215
|
+
<Animated.View
|
|
216
|
+
style={[
|
|
217
|
+
styles.expandedContentContainer,
|
|
218
|
+
{
|
|
219
|
+
transform: [
|
|
220
|
+
{ translateX: xPosition },
|
|
221
|
+
{ translateY: yPosition },
|
|
222
|
+
{ scale: scalePosition },
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
]}
|
|
226
|
+
>
|
|
227
|
+
{content}
|
|
228
|
+
</Animated.View>
|
|
229
|
+
{extraContent ? (
|
|
230
|
+
<GestureAnimatedScrollView
|
|
231
|
+
ref={scrollViewRef}
|
|
232
|
+
contentContainerStyle={getExtraContentPadding(insets)}
|
|
233
|
+
bounces={false}
|
|
234
|
+
overScrollMode="never"
|
|
235
|
+
onLayout={onScrollViewLayout}
|
|
236
|
+
style={[
|
|
237
|
+
styles.extraContentScrollView,
|
|
238
|
+
{ opacity: expandedOpacity },
|
|
239
|
+
]}
|
|
240
|
+
>
|
|
241
|
+
<PlayerDetailsWrapperHeightContext.Provider
|
|
242
|
+
value={playerDetailsWrapperHeight}
|
|
243
|
+
>
|
|
244
|
+
{extraContent}
|
|
245
|
+
</PlayerDetailsWrapperHeightContext.Provider>
|
|
246
|
+
</GestureAnimatedScrollView>
|
|
247
|
+
) : null}
|
|
222
248
|
</Animated.View>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
paddingBottom: insets.bottom,
|
|
228
|
-
}}
|
|
229
|
-
onLayout={onScrollViewLayout}
|
|
249
|
+
|
|
250
|
+
{!isFullScreenOrPIP ? (
|
|
251
|
+
<Animated.View
|
|
252
|
+
pointerEvents={collapsed ? "box-none" : "none"}
|
|
230
253
|
style={[
|
|
231
|
-
styles.
|
|
232
|
-
{ opacity:
|
|
254
|
+
styles.collapsedBarContainer,
|
|
255
|
+
{ opacity: collapsedOpacity },
|
|
233
256
|
]}
|
|
234
257
|
>
|
|
235
|
-
<
|
|
236
|
-
|
|
258
|
+
<Pressable
|
|
259
|
+
testID="collapsedBarWrapper"
|
|
260
|
+
onPress={expand}
|
|
261
|
+
style={styles.collapsedBarWrapper}
|
|
237
262
|
>
|
|
238
|
-
{
|
|
239
|
-
</
|
|
240
|
-
</
|
|
263
|
+
{collapsedContent}
|
|
264
|
+
</Pressable>
|
|
265
|
+
</Animated.View>
|
|
241
266
|
) : null}
|
|
242
267
|
</Animated.View>
|
|
243
|
-
|
|
244
|
-
{!isFullScreenOrPIP ? (
|
|
245
|
-
<Animated.View
|
|
246
|
-
pointerEvents={collapsed ? "box-none" : "none"}
|
|
247
|
-
style={[
|
|
248
|
-
styles.collapsedBarContainer,
|
|
249
|
-
{ opacity: collapsedOpacity },
|
|
250
|
-
]}
|
|
251
|
-
>
|
|
252
|
-
<Pressable
|
|
253
|
-
testID="collapsedBarWrapper"
|
|
254
|
-
onPress={expand}
|
|
255
|
-
style={styles.collapsedBarWrapper}
|
|
256
|
-
>
|
|
257
|
-
{collapsedContent}
|
|
258
|
-
</Pressable>
|
|
259
|
-
</Animated.View>
|
|
260
|
-
) : null}
|
|
261
268
|
</Animated.View>
|
|
262
|
-
</
|
|
269
|
+
</SafeAreaView>
|
|
263
270
|
</PanGestureHandler>
|
|
264
271
|
);
|
|
265
272
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
|
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) + // insets.bottom is added to properly display docked modal
|
|
53
53
|
PROGRESS_BAR_HEIGHT;
|
|
54
54
|
|
|
55
|
-
const heightAboveMinimised =
|
|
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
|
-
}, [
|
|
182
|
+
}, [
|
|
183
|
+
videoModalState.visible,
|
|
184
|
+
videoModalState.mode,
|
|
185
|
+
collapsedHeight,
|
|
186
|
+
heightAboveMinimised,
|
|
187
|
+
]);
|
|
183
188
|
|
|
184
189
|
return useMemo(
|
|
185
190
|
() => ({
|
|
@@ -63,6 +63,7 @@ export const useStyles = ({ height }: { height: number }) => {
|
|
|
63
63
|
backgroundColor,
|
|
64
64
|
elevation: 10,
|
|
65
65
|
zIndex: 100,
|
|
66
|
+
height: "100%",
|
|
66
67
|
overflow: "hidden",
|
|
67
68
|
},
|
|
68
69
|
modalWrapper: {
|
|
@@ -75,6 +76,10 @@ export const useStyles = ({ height }: { height: number }) => {
|
|
|
75
76
|
flex: 1,
|
|
76
77
|
alignItems: "center",
|
|
77
78
|
},
|
|
79
|
+
modalContentPiP: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
alignItems: "flex-start",
|
|
82
|
+
},
|
|
78
83
|
expandedContentContainer: {
|
|
79
84
|
justifyContent: "flex-start",
|
|
80
85
|
backgroundColor: BG_COLOR_DEFAULT_TRANSPARENT,
|
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyleSheet, Dimensions, ViewStyle } from "react-native";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
isAndroidPlatform,
|
|
5
5
|
isAndroidVersionAtLeast,
|
|
6
|
+
isTV,
|
|
6
7
|
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
isTablet,
|
|
10
|
+
useIsTablet as getIsTablet,
|
|
11
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
8
12
|
|
|
9
|
-
const
|
|
13
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
10
14
|
|
|
11
|
-
const isOldAndroidDevice =
|
|
15
|
+
export const isOldAndroidDevice =
|
|
12
16
|
isAndroidPlatform() &&
|
|
13
|
-
!isAndroidVersionAtLeast(
|
|
14
|
-
!isAndroidTablet();
|
|
17
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
|
|
15
18
|
|
|
16
19
|
export const getWindowHeight = (): number => {
|
|
17
20
|
const windowDimensions = Dimensions.get("window");
|
|
18
21
|
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
return windowDimensions.height;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const getScreenHeight = (): number => {
|
|
26
|
+
const screenDimensions = Dimensions.get("screen");
|
|
27
|
+
|
|
28
|
+
return screenDimensions.height;
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
export const getWindowWidth = (): number => {
|
|
@@ -27,3 +33,60 @@ export const getWindowWidth = (): number => {
|
|
|
27
33
|
|
|
28
34
|
return windowDimensions.width;
|
|
29
35
|
};
|
|
36
|
+
|
|
37
|
+
const getIsTabletLandscape = (isTabletPortrait: boolean): boolean => {
|
|
38
|
+
return !isTV() && isTablet() && !isTabletPortrait;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const getInsetsOffset = (
|
|
42
|
+
insets: { top: number; bottom: number },
|
|
43
|
+
isTabletPortrait: boolean
|
|
44
|
+
): number => {
|
|
45
|
+
const isTabletLandscape = getIsTabletLandscape(isTabletPortrait);
|
|
46
|
+
|
|
47
|
+
return isTablet() && isTabletLandscape
|
|
48
|
+
? isOldAndroidDevice
|
|
49
|
+
? insets.top / 2
|
|
50
|
+
: 0
|
|
51
|
+
: insets.top / 2;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const orientationStyles = StyleSheet.create({
|
|
55
|
+
landscape: { flexDirection: "row" },
|
|
56
|
+
portrait: { flexDirection: "column" },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const directionStyles = (isTabletPortrait: boolean): ViewStyle => {
|
|
60
|
+
const isTabletLandscape = getIsTabletLandscape(isTabletPortrait);
|
|
61
|
+
|
|
62
|
+
return isTabletLandscape
|
|
63
|
+
? orientationStyles.landscape
|
|
64
|
+
: orientationStyles.portrait;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const getScaledPos = (
|
|
68
|
+
height,
|
|
69
|
+
vidHeight,
|
|
70
|
+
minimisedHeight,
|
|
71
|
+
isTabletPortrait
|
|
72
|
+
) => {
|
|
73
|
+
const isTabletLandscape = getIsTabletLandscape(isTabletPortrait);
|
|
74
|
+
|
|
75
|
+
const SCALE_FACTOR = minimisedHeight / vidHeight; // Scale factor for expanded content
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
((isTabletLandscape ? height : vidHeight) - vidHeight * SCALE_FACTOR) / 2
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const getExtraContentPadding = (insets: {
|
|
83
|
+
top: number;
|
|
84
|
+
bottom: number;
|
|
85
|
+
}): ViewStyle => {
|
|
86
|
+
const isTablet = getIsTablet(); // not a hook, just a utility function
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
paddingTop: isTablet ? insets.top : 0,
|
|
90
|
+
paddingBottom: insets.bottom,
|
|
91
|
+
};
|
|
92
|
+
};
|
package/src/Player/index.tsx
CHANGED
|
@@ -835,25 +835,25 @@ export default class VideoPlayer extends React.Component<
|
|
|
835
835
|
: styles.playerContainerBlack;
|
|
836
836
|
|
|
837
837
|
private getBackgroundImageStyle = (
|
|
838
|
-
dimensions:
|
|
838
|
+
dimensions: ViewStyle,
|
|
839
839
|
isAudioItem: boolean
|
|
840
|
-
): ViewStyle =>
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
840
|
+
): ViewStyle[] => [
|
|
841
|
+
isAudioItem ? styles.audio : { position: "absolute" },
|
|
842
|
+
dimensions,
|
|
843
|
+
];
|
|
844
844
|
|
|
845
845
|
/* Returns player view style based on platform and content type (audio/video) */
|
|
846
846
|
private getPlayerViewStyle = (
|
|
847
847
|
dimensions: ViewStyle,
|
|
848
848
|
isAudioItem: boolean
|
|
849
|
-
): ViewStyle => {
|
|
850
|
-
const generalStyles = isAudioItem ? styles.audio :
|
|
849
|
+
): ViewStyle | ViewStyle[] => {
|
|
850
|
+
const generalStyles = isAudioItem ? styles.audio : undefined;
|
|
851
851
|
|
|
852
852
|
if (isAndroidPlatform() && isAudioItem) {
|
|
853
853
|
return generalStyles;
|
|
854
854
|
}
|
|
855
855
|
|
|
856
|
-
return
|
|
856
|
+
return [generalStyles, dimensions];
|
|
857
857
|
};
|
|
858
858
|
|
|
859
859
|
private renderAudioPlayer = (
|
|
@@ -876,7 +876,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
876
876
|
shouldRender: boolean,
|
|
877
877
|
imageKey: string,
|
|
878
878
|
entry: ZappEntry,
|
|
879
|
-
style: ViewStyle
|
|
879
|
+
style: ViewStyle | ViewStyle[]
|
|
880
880
|
) => {
|
|
881
881
|
if (!shouldRender) return null;
|
|
882
882
|
|
|
@@ -887,7 +887,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
887
887
|
|
|
888
888
|
private renderNativePlayer = (
|
|
889
889
|
shouldRender: boolean,
|
|
890
|
-
style: ViewStyle,
|
|
890
|
+
style: ViewStyle | ViewStyle[],
|
|
891
891
|
nativeEvents: ReturnType<typeof this.getNativeEvents>,
|
|
892
892
|
nativeProps: ReturnType<typeof this.getNativeProps>,
|
|
893
893
|
pluginConfiguration: Record<string, any>
|
|
@@ -1128,10 +1128,10 @@ export default class VideoPlayer extends React.Component<
|
|
|
1128
1128
|
isTV() && this.getPlayNextData() && !docked;
|
|
1129
1129
|
|
|
1130
1130
|
const needsToRender =
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
docked;
|
|
1131
|
+
!hideTransportControls &&
|
|
1132
|
+
!needToShowPlayNextOverlay &&
|
|
1133
|
+
this.props.mode !== "PIP" &&
|
|
1134
|
+
!docked;
|
|
1135
1135
|
|
|
1136
1136
|
const supportsNativeControls =
|
|
1137
1137
|
!!this.props.controller?.supportsNativeControls?.();
|
|
@@ -1265,13 +1265,13 @@ export default class VideoPlayer extends React.Component<
|
|
|
1265
1265
|
</View>
|
|
1266
1266
|
}
|
|
1267
1267
|
/>
|
|
1268
|
-
) : (
|
|
1268
|
+
) : isModal ? (
|
|
1269
1269
|
<VideoPlayerModal
|
|
1270
1270
|
isTabletPortrait={isTabletPortrait}
|
|
1271
1271
|
aspectRatio={aspectRatio}
|
|
1272
1272
|
pip={piped}
|
|
1273
1273
|
fullscreen={fullscreen}
|
|
1274
|
-
modal
|
|
1274
|
+
modal
|
|
1275
1275
|
style={{
|
|
1276
1276
|
tabletLandscapeWidth: getTabletWidth(
|
|
1277
1277
|
this.getPluginConfiguration().tablet_landscape_sidebar_width,
|
|
@@ -1309,6 +1309,13 @@ export default class VideoPlayer extends React.Component<
|
|
|
1309
1309
|
</View>
|
|
1310
1310
|
}
|
|
1311
1311
|
/>
|
|
1312
|
+
) : (
|
|
1313
|
+
<View style={style} testID={"player-view"}>
|
|
1314
|
+
<PlayerWrapper
|
|
1315
|
+
{...sharedWrapperViewProps}
|
|
1316
|
+
playerContent={this.renderPlayerContent}
|
|
1317
|
+
/>
|
|
1318
|
+
</View>
|
|
1312
1319
|
);
|
|
1313
1320
|
};
|
|
1314
1321
|
|