@applicaster/quick-brick-player 14.0.0-rc.4 → 14.0.0-rc.40

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.
@@ -0,0 +1,254 @@
1
+ import React, { useRef, ReactElement } from "react";
2
+
3
+ import { StyleSheet, Animated, Pressable, ViewStyle } from "react-native";
4
+ import { PanGestureHandler } from "react-native-gesture-handler";
5
+ import { useStyles } from "./styles";
6
+ import { useConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
7
+ import { useVideoModalState } from "./hooks";
8
+ import {
9
+ DEFAULT_IMAGE_RATIO_VIDEO,
10
+ MODAL_COLLAPSE_START,
11
+ MODAL_RADIUS,
12
+ SCREEN_HEIGHT,
13
+ SCREEN_WIDTH,
14
+ VIDEO_TRANSITION_THRESHOLD,
15
+ } from "./consts";
16
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
17
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
18
+ import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext";
19
+ import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
20
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
21
+ import { GestureAnimatedScrollView } from "./GestureAnimatedScrollView";
22
+
23
+ const orientationStyles = StyleSheet.create({
24
+ landscape: { flexDirection: "row" },
25
+ portrait: { flexDirection: "column" },
26
+ });
27
+
28
+ const directionStyles = (isLandscape: boolean): ViewStyle => {
29
+ return isLandscape ? orientationStyles.landscape : orientationStyles.portrait;
30
+ };
31
+
32
+ type AnimatedModalProps = {
33
+ enabled?: boolean;
34
+ pip?: boolean;
35
+ fullscreen?: boolean;
36
+ content?: (
37
+ opacity: Animated.Value | Animated.AnimatedInterpolation<number>
38
+ ) => ReactElement;
39
+ collapsedContent?: (
40
+ opacity: Animated.Value | Animated.AnimatedInterpolation<number>
41
+ ) => ReactElement;
42
+ extraContent?: (
43
+ opacity: Animated.Value | Animated.AnimatedInterpolation<number>
44
+ ) => ReactElement;
45
+ aspectRatio?: number;
46
+ isTabletPortrait?: boolean;
47
+ style?: {
48
+ tabletLandscapeWidth?: number;
49
+ width?: number;
50
+ height?: number;
51
+ };
52
+ };
53
+
54
+ const height = SCREEN_HEIGHT;
55
+
56
+ export function VideoPlayerModal({
57
+ enabled = true,
58
+ aspectRatio = DEFAULT_IMAGE_RATIO_VIDEO,
59
+ content,
60
+ extraContent,
61
+ collapsedContent,
62
+ isTabletPortrait,
63
+ style,
64
+ pip = false,
65
+ fullscreen = false,
66
+ }: AnimatedModalProps) {
67
+ const isTablet = useIsTablet();
68
+
69
+ let width = SCREEN_WIDTH;
70
+
71
+ if (isTablet && !isTabletPortrait) {
72
+ width = style?.tabletLandscapeWidth || width;
73
+ }
74
+
75
+ const { minimised_height: minimisedHeight } = useConfiguration();
76
+ const scrollViewRef = useRef<typeof Animated.ScrollView | null>(null);
77
+
78
+ const translateYRef = useModalAnimationContext().yTranslate;
79
+
80
+ const {
81
+ translateY,
82
+ collapsed,
83
+ collapsedHeight,
84
+ gestureHandlerProps,
85
+ expand,
86
+ } = useVideoModalState(translateYRef);
87
+
88
+ const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
89
+
90
+ const styles = useStyles({ height: collapsedHeight });
91
+
92
+ const SCALE_FACTOR = 1 / (width / aspectRatio / minimisedHeight); // Scale factor for expanded content
93
+
94
+ const insets = useSafeAreaInsets();
95
+
96
+ const isFullScreenOrPIP = fullscreen || pip;
97
+
98
+ // Interpolated opacities for smooth cross-fade
99
+ const collapsedOpacity = !isFullScreenOrPIP
100
+ ? translateY.interpolate({
101
+ inputRange: [MODAL_COLLAPSE_START, height - collapsedHeight],
102
+ outputRange: [0, 1],
103
+ extrapolate: "clamp",
104
+ })
105
+ : new Animated.Value(0);
106
+
107
+ const expandedOpacity = !isFullScreenOrPIP
108
+ ? translateY.interpolate({
109
+ inputRange: [0, height - collapsedHeight],
110
+ outputRange: [1, 0],
111
+ extrapolate: "clamp",
112
+ })
113
+ : new Animated.Value(1);
114
+
115
+ const xPosition = !isFullScreenOrPIP
116
+ ? translateY.interpolate({
117
+ inputRange: [
118
+ height * VIDEO_TRANSITION_THRESHOLD,
119
+ height - collapsedHeight,
120
+ ],
121
+ outputRange: [0, -(width - width * SCALE_FACTOR) / 2],
122
+ extrapolate: "clamp",
123
+ })
124
+ : new Animated.Value(0);
125
+
126
+ const vidHeight = width / aspectRatio;
127
+
128
+ const yPosition = !isFullScreenOrPIP
129
+ ? translateY.interpolate({
130
+ inputRange: [
131
+ height * VIDEO_TRANSITION_THRESHOLD,
132
+ height - collapsedHeight,
133
+ ],
134
+ outputRange: [
135
+ 0,
136
+ isTablet && isTabletLandscape
137
+ ? -((-PROGRESS_BAR_HEIGHT + height - vidHeight * SCALE_FACTOR) / 2)
138
+ : -(
139
+ PROGRESS_BAR_HEIGHT +
140
+ insets.top / 2 +
141
+ (SCREEN_WIDTH / aspectRatio -
142
+ (SCREEN_WIDTH / aspectRatio) * SCALE_FACTOR) /
143
+ 2
144
+ ),
145
+ ],
146
+ extrapolate: "clamp",
147
+ })
148
+ : new Animated.Value(0);
149
+
150
+ const scalePosition = !isFullScreenOrPIP
151
+ ? translateY.interpolate({
152
+ inputRange: [
153
+ height * VIDEO_TRANSITION_THRESHOLD,
154
+ height - collapsedHeight,
155
+ ],
156
+ outputRange: [1, SCALE_FACTOR],
157
+ extrapolate: "clamp",
158
+ })
159
+ : new Animated.Value(1);
160
+
161
+ const borderTopRadiusAnimated = !isFullScreenOrPIP
162
+ ? translateY.interpolate({
163
+ inputRange: [0, height - collapsedHeight],
164
+ outputRange: [MODAL_RADIUS, 0],
165
+ extrapolate: "clamp",
166
+ })
167
+ : new Animated.Value(0);
168
+
169
+ return (
170
+ <PanGestureHandler
171
+ enabled={enabled}
172
+ waitFor={scrollViewRef}
173
+ {...gestureHandlerProps}
174
+ >
175
+ <Animated.View
176
+ pointerEvents={"auto"}
177
+ style={[
178
+ styles.modalWrapper,
179
+ {
180
+ borderTopLeftRadius: borderTopRadiusAnimated,
181
+ borderTopRightRadius: borderTopRadiusAnimated,
182
+ transform: [{ translateY: isFullScreenOrPIP ? 0 : translateY }],
183
+ height: height,
184
+ },
185
+ ]}
186
+ >
187
+ <Animated.View
188
+ pointerEvents={"auto"}
189
+ style={[
190
+ styles.modal,
191
+ collapsed ? styles.collapsedModalBg : null,
192
+ {
193
+ borderTopLeftRadius: borderTopRadiusAnimated,
194
+ borderTopRightRadius: borderTopRadiusAnimated,
195
+ height: height,
196
+ },
197
+ ]}
198
+ >
199
+ <Animated.View
200
+ pointerEvents={!collapsed ? "auto" : "none"}
201
+ style={[styles.modalContent, directionStyles(isTabletLandscape)]}
202
+ >
203
+ <Animated.View
204
+ style={[
205
+ styles.expandedContentContainer,
206
+ {
207
+ transform: [
208
+ { translateX: xPosition },
209
+ { translateY: yPosition },
210
+ { scale: scalePosition },
211
+ ],
212
+ },
213
+ ]}
214
+ >
215
+ {content(expandedOpacity)}
216
+ </Animated.View>
217
+ {extraContent ? (
218
+ <GestureAnimatedScrollView
219
+ ref={scrollViewRef}
220
+ contentContainerStyle={{
221
+ paddingBottom: insets.bottom,
222
+ }}
223
+ style={[
224
+ styles.extraContentScrollView,
225
+ { opacity: expandedOpacity },
226
+ ]}
227
+ >
228
+ {extraContent ? extraContent(expandedOpacity) : null}
229
+ </GestureAnimatedScrollView>
230
+ ) : null}
231
+ </Animated.View>
232
+
233
+ {!isFullScreenOrPIP ? (
234
+ <Animated.View
235
+ pointerEvents={collapsed ? "box-none" : "none"}
236
+ style={[
237
+ styles.collapsedBarContainer,
238
+ { opacity: collapsedOpacity },
239
+ ]}
240
+ >
241
+ <Pressable
242
+ testID="collapsedBarWrapper"
243
+ onPress={expand}
244
+ style={styles.collapsedBarWrapper}
245
+ >
246
+ {collapsedContent}
247
+ </Pressable>
248
+ </Animated.View>
249
+ ) : null}
250
+ </Animated.View>
251
+ </Animated.View>
252
+ </PanGestureHandler>
253
+ );
254
+ }
@@ -0,0 +1,34 @@
1
+ import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
2
+ import {
3
+ isAndroidPlatform,
4
+ isAndroidVersionAtLeast,
5
+ } from "@applicaster/zapp-react-native-utils/reactUtils";
6
+ import { Dimensions, StatusBar } from "react-native";
7
+
8
+ export const DOCKED_PROGRESSBAR_HEIGHT = 3; // Height of the docked progress bar plugins/mobile-transport-controls/src/ProgressBar/layouts/DockedLayout.tsx
9
+
10
+ export const VIDEO_TRANSITION_THRESHOLD = 0.5; // Threshold for video transition
11
+
12
+ const windowDimensions = Dimensions.get("window");
13
+
14
+ const isOldAndroidDevice =
15
+ isAndroidPlatform() && !isAndroidVersionAtLeast(35) && !isAndroidTablet();
16
+
17
+ export const SCREEN_WIDTH = windowDimensions.width;
18
+
19
+ export const SCREEN_HEIGHT =
20
+ windowDimensions.height + (isOldAndroidDevice ? StatusBar.currentHeight : 0);
21
+
22
+ export const MODAL_COLLAPSE_START = SCREEN_HEIGHT * 0.7; // 70% of screen height
23
+
24
+ export const DRAG_TO_COLLAPSE = 0.02; // 2% to collapse
25
+
26
+ export const DRAG_TO_EXPAND = 0.02; // 2% to expand
27
+
28
+ export const DEFAULT_IMAGE_RATIO_VIDEO = 16 / 9; // Default aspect ratio for video
29
+
30
+ export const DEFAULT_IMAGE_RATIO_AUDIO = 1; // Default aspect ratio for audio
31
+
32
+ export const ANIMATION_DURATION = 250; // Default animation duration in milliseconds
33
+
34
+ export const MODAL_RADIUS = 16; // Default border radius for modal
@@ -0,0 +1,161 @@
1
+ import { VideoModalMode } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
2
+ import { useConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
3
+ import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
5
+ import { useCallback, useEffect, useMemo, useRef } from "react";
6
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
7
+ import {
8
+ ANIMATION_DURATION,
9
+ DRAG_TO_COLLAPSE,
10
+ DRAG_TO_EXPAND,
11
+ SCREEN_HEIGHT,
12
+ } from "../consts";
13
+ import { State } from "react-native-gesture-handler";
14
+ import { Animated } from "react-native";
15
+ import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
16
+
17
+ const bottomTabBarHeight = getTabBarHeight();
18
+
19
+ export const useVideoModalState = (
20
+ translateYRef: React.MutableRefObject<Animated.Value>
21
+ ) => {
22
+ const { minimised_height: minimisedHeight } = useConfiguration();
23
+
24
+ const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
25
+ useNavigation();
26
+
27
+ const collapsed = videoModalState.mode === VideoModalMode.MINIMIZED;
28
+
29
+ const { bottom } = useSafeAreaInsets();
30
+
31
+ const collapsedHeight =
32
+ minimisedHeight + bottom + bottomTabBarHeight + PROGRESS_BAR_HEIGHT;
33
+
34
+ const translateY = translateYRef.current;
35
+
36
+ const handleExpand = useCallback(
37
+ (toValue: number) => {
38
+ return Animated.timing(translateYRef.current, {
39
+ toValue,
40
+ duration: ANIMATION_DURATION,
41
+ useNativeDriver: true,
42
+ });
43
+ },
44
+ [translateYRef]
45
+ );
46
+
47
+ const handleCollapse = useCallback(
48
+ (toValue: number) => {
49
+ return Animated.timing(translateYRef.current, {
50
+ toValue,
51
+ duration: ANIMATION_DURATION,
52
+ useNativeDriver: true,
53
+ });
54
+ },
55
+ [translateYRef]
56
+ );
57
+
58
+ const offset = useRef(SCREEN_HEIGHT - collapsedHeight);
59
+
60
+ // Gesture handler for modal
61
+ const onGestureEvent = (event: any) => {
62
+ if (event.nativeEvent.state === State.ACTIVE) {
63
+ const y = event.nativeEvent.translationY;
64
+ let newY = offset.current + y;
65
+ if (newY < 0) newY = 0;
66
+
67
+ if (newY > SCREEN_HEIGHT - collapsedHeight) {
68
+ newY = SCREEN_HEIGHT - collapsedHeight;
69
+ }
70
+
71
+ translateY.setValue(newY);
72
+ }
73
+ };
74
+
75
+ const onHandlerStateChange = (event: any) => {
76
+ if (event.nativeEvent.oldState === State.ACTIVE) {
77
+ const { translationY } = event.nativeEvent;
78
+ let newY = offset.current + translationY;
79
+ if (newY < 0) newY = 0;
80
+
81
+ if (newY > SCREEN_HEIGHT - collapsedHeight) {
82
+ newY = SCREEN_HEIGHT - collapsedHeight;
83
+ }
84
+
85
+ const shouldCollapse =
86
+ translationY > (SCREEN_HEIGHT - collapsedHeight) * DRAG_TO_COLLAPSE;
87
+
88
+ const shouldExpand =
89
+ translationY < -(SCREEN_HEIGHT - collapsedHeight) * DRAG_TO_EXPAND;
90
+
91
+ if (!collapsed && shouldCollapse) {
92
+ // Collapse
93
+ Animated.timing(translateY, {
94
+ toValue: SCREEN_HEIGHT - collapsedHeight,
95
+ duration: ANIMATION_DURATION,
96
+ useNativeDriver: true,
97
+ }).start(() => {
98
+ minimiseVideoModal();
99
+ offset.current = SCREEN_HEIGHT - collapsedHeight;
100
+ });
101
+ } else if (collapsed && shouldExpand) {
102
+ // Expand
103
+ Animated.timing(translateY, {
104
+ toValue: 0,
105
+ duration: ANIMATION_DURATION,
106
+ useNativeDriver: true,
107
+ }).start(() => {
108
+ maximiseVideoModal();
109
+ offset.current = 0;
110
+ translateY.setValue(0);
111
+ });
112
+ } else {
113
+ // Snap back to current state
114
+ Animated.spring(translateY, {
115
+ toValue: collapsed ? SCREEN_HEIGHT - collapsedHeight : 0,
116
+ useNativeDriver: true,
117
+ }).start(() => {
118
+ offset.current = collapsed ? SCREEN_HEIGHT - collapsedHeight : 0;
119
+ translateY.setValue(offset.current);
120
+ });
121
+ }
122
+ } else if (event.nativeEvent.state === State.BEGAN) {
123
+ // Gesture started, set offset
124
+ translateY.stopAnimation((value: number) => {
125
+ offset.current = value;
126
+ });
127
+ }
128
+ };
129
+
130
+ const gestureHandlerProps = useMemo(() => {
131
+ return {
132
+ onGestureEvent,
133
+ onHandlerStateChange,
134
+ };
135
+ }, [onGestureEvent, onHandlerStateChange]);
136
+
137
+ useEffect(() => {
138
+ if (videoModalState.mode === VideoModalMode.MAXIMIZED) {
139
+ handleExpand(0).start(() => {
140
+ maximiseVideoModal();
141
+ offset.current = 0;
142
+ translateY.setValue(0);
143
+ });
144
+ } else if (videoModalState.mode === VideoModalMode.MINIMIZED) {
145
+ handleCollapse(SCREEN_HEIGHT - collapsedHeight).start(() => {
146
+ minimiseVideoModal();
147
+ offset.current = SCREEN_HEIGHT - collapsedHeight;
148
+ translateY.setValue(SCREEN_HEIGHT - collapsedHeight);
149
+ });
150
+ }
151
+ }, [videoModalState.visible, videoModalState.mode]);
152
+
153
+ return {
154
+ collapsed,
155
+ collapsedHeight,
156
+ offset,
157
+ gestureHandlerProps,
158
+ translateY,
159
+ expand: maximiseVideoModal,
160
+ };
161
+ };
@@ -0,0 +1,3 @@
1
+ export { AnimatedModal as default } from "./PlayerModal";
2
+
3
+ export { VideoPlayerModal } from "./VideoPlayerModal";
@@ -0,0 +1,101 @@
1
+ import { useConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
2
+ import {
3
+ useIsTablet,
4
+ useNavigation,
5
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
+ import { useMemo } from "react";
8
+ import { StyleSheet } from "react-native";
9
+
10
+ export const useBackgroundColor = (): string => {
11
+ const {
12
+ modal_background_color: modalBackgroundColor,
13
+ tablet_landscape_player_container_background_color: tabletBackgroundColor,
14
+ } = useConfiguration();
15
+
16
+ const {
17
+ videoModalState: { mode },
18
+ } = useNavigation();
19
+
20
+ const isTablet = useIsTablet();
21
+
22
+ const theme = useTheme<BaseThemePropertiesMobile>();
23
+ const isFullscreen = mode === "FULLSCREEN";
24
+
25
+ /**
26
+ * For the new audio player, the background color setting work that way
27
+ * Layer 0 - modal_background_color
28
+ * Layer 1 - screen_background_color ( can be combined with layer 0 ), If the parameter is not set, it will be a solid black.
29
+ * audio_player_background_color is used only in the old player when the background image is not set
30
+ * modal_background_color is used as the background for player details, and in useBackgroundColor to set a background for a video modal.
31
+ * If it’s not set, theme?.status_background_color will be used instead
32
+ *
33
+ * This hook cover only case with layer 0: modal_background_color, layer 1: screen_background_color is used in the styles.expandedContentContainer
34
+ *
35
+ * For the video player, inline player will use tablet_landscape_player_container_background_color as background color, and transparent for fullscreen.
36
+ * Mobile player will use
37
+ * modal_background_color as background color.
38
+ */
39
+
40
+ return isTablet
41
+ ? !isFullscreen
42
+ ? tabletBackgroundColor
43
+ : "transparent"
44
+ : modalBackgroundColor || theme?.status_background_color;
45
+ };
46
+
47
+ export const useStyles = ({ height }: { height: number }) => {
48
+ const COLLAPSED_HEIGHT = height;
49
+
50
+ const backgroundColor = useBackgroundColor();
51
+
52
+ const BG_COLOR_DEFAULT_BLACK = "black";
53
+ const BG_COLOR_DEFAULT_TRANSPARENT = "transparent";
54
+
55
+ const styles = StyleSheet.create({
56
+ modal: {
57
+ position: "absolute",
58
+ left: 0,
59
+ right: 0,
60
+ top: 0,
61
+ backgroundColor,
62
+ elevation: 10,
63
+ zIndex: 100,
64
+ overflow: "hidden",
65
+ },
66
+ modalWrapper: {
67
+ backgroundColor: BG_COLOR_DEFAULT_BLACK,
68
+ },
69
+ collapsedModalBg: {
70
+ backgroundColor: BG_COLOR_DEFAULT_BLACK,
71
+ },
72
+ modalContent: {
73
+ flex: 1,
74
+ alignItems: "center",
75
+ },
76
+ expandedContentContainer: {
77
+ justifyContent: "flex-start",
78
+ backgroundColor: BG_COLOR_DEFAULT_TRANSPARENT,
79
+ zIndex: 1,
80
+ flex: 0,
81
+ },
82
+ extraContentScrollView: {
83
+ width: "100%",
84
+ backgroundColor: BG_COLOR_DEFAULT_TRANSPARENT,
85
+ },
86
+ collapsedBarContainer: {
87
+ ...StyleSheet.absoluteFillObject,
88
+ height: COLLAPSED_HEIGHT,
89
+ justifyContent: "flex-end",
90
+ },
91
+ collapsedBarWrapper: {
92
+ flex: 1,
93
+ },
94
+ flexNone: {
95
+ ...StyleSheet.absoluteFillObject,
96
+ flex: -1,
97
+ },
98
+ });
99
+
100
+ return useMemo(() => styles, [styles]);
101
+ };
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import { PlayNextOverlay } from "../PlayNextOverlay";
3
+ import { GenericTVPlayerViewProps } from "./types";
4
+ import { AudioPlayer } from "@applicaster/zapp-react-native-ui-components/Components/AudioPlayer";
5
+
6
+ export const GenericTVPlayerView: React.FC<GenericTVPlayerViewProps> = ({
7
+ children,
8
+ type,
9
+ PlayerComponent,
10
+ pluginConfiguration,
11
+ playerProps,
12
+ playNextProps,
13
+ audioPlayerProps,
14
+ transportControls,
15
+ entry,
16
+ }) => {
17
+ return (
18
+ <>
19
+ {type === "audio" ? (
20
+ <AudioPlayer
21
+ audio_item={entry}
22
+ plugin_configuration={pluginConfiguration}
23
+ {...audioPlayerProps}
24
+ />
25
+ ) : null}
26
+ <PlayerComponent
27
+ pluginConfiguration={pluginConfiguration}
28
+ {...playerProps}
29
+ >
30
+ {children}
31
+ </PlayerComponent>
32
+ {transportControls}
33
+ {playNextProps.playNextData ? (
34
+ <PlayNextOverlay
35
+ item={entry}
36
+ pluginConfiguration={pluginConfiguration}
37
+ {...playNextProps}
38
+ />
39
+ ) : null}
40
+ </>
41
+ );
42
+ };
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { isTvOSPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
3
+ import { TvOSPlayerView } from "./TvOSPlayerView";
4
+ import { GenericTVPlayerView } from "./GenericTVPlayerView";
5
+ import {
6
+ GenericTVPlayerViewProps,
7
+ TvOSPlayerViewProps,
8
+ TVPlayerViewProps,
9
+ } from "./types";
10
+
11
+ const isTvOS = isTvOSPlatform();
12
+
13
+ const shouldRenderTvOSPlayerView = (
14
+ isTvOS: boolean,
15
+ inline: boolean
16
+ ): boolean => {
17
+ return isTvOS && !inline;
18
+ };
19
+
20
+ export const TVPlayerView: React.FC<TVPlayerViewProps> = (props) => {
21
+ return shouldRenderTvOSPlayerView(isTvOS, props.inline) ? (
22
+ <TvOSPlayerView {...(props as TvOSPlayerViewProps)} />
23
+ ) : (
24
+ <GenericTVPlayerView {...(props as GenericTVPlayerViewProps)} />
25
+ );
26
+ };
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { PlayNextOverlay } from "../PlayNextOverlay";
4
+ import { TvOSPlayerViewProps } from "./types";
5
+
6
+ const AUDIO_PLAYER_NATIVE_ID = "audio-player-view";
7
+
8
+ export const TvOSPlayerView: React.FC<TvOSPlayerViewProps> = ({
9
+ children,
10
+ type,
11
+ PlayerComponent,
12
+ pluginConfiguration,
13
+ playerProps,
14
+ playNextProps,
15
+ nativePlayerIsReady,
16
+ transportControls,
17
+ entry,
18
+ inline,
19
+ }) => {
20
+ return (
21
+ <>
22
+ <PlayerComponent
23
+ pluginConfiguration={pluginConfiguration}
24
+ {...playerProps}
25
+ >
26
+ {!inline ? (
27
+ <>
28
+ {type === "audio" && nativePlayerIsReady ? (
29
+ <View
30
+ nativeID={AUDIO_PLAYER_NATIVE_ID}
31
+ key={AUDIO_PLAYER_NATIVE_ID}
32
+ >
33
+ {children}
34
+ </View>
35
+ ) : (
36
+ children
37
+ )}
38
+ {playNextProps.playNextData ? (
39
+ <PlayNextOverlay
40
+ item={entry}
41
+ pluginConfiguration={pluginConfiguration}
42
+ {...playNextProps}
43
+ />
44
+ ) : null}
45
+ </>
46
+ ) : null}
47
+ </PlayerComponent>
48
+ {transportControls}
49
+ </>
50
+ );
51
+ };