@applicaster/quick-brick-player 14.0.0-rc.2 → 14.0.0-rc.20

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.2",
3
+ "version": "14.0.0-rc.20",
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": "13.0.0-rc.124",
39
- "@applicaster/quick-brick-tv-transport-controls": "13.0.0-rc.56",
40
- "@applicaster/zapp-react-native-tvos-app": "14.0.0-rc.2",
41
- "@applicaster/zapp-react-native-ui-components": "14.0.0-rc.2",
42
- "@applicaster/zapp-react-native-utils": "14.0.0-rc.2",
38
+ "@applicaster/quick-brick-mobile-transport-controls": "14.0.0-rc.16",
39
+ "@applicaster/quick-brick-tv-transport-controls": "14.0.0-rc.13",
40
+ "@applicaster/zapp-react-native-tvos-app": "14.0.0-rc.20",
41
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-rc.20",
42
+ "@applicaster/zapp-react-native-utils": "14.0.0-rc.20",
43
43
  "query-string": "7.1.3",
44
44
  "react-native-web-linear-gradient": "1.1.2",
45
45
  "shaka-player": "4.3.5",
@@ -1,7 +1,6 @@
1
1
  import React, { PropsWithChildren } from "react";
2
2
  import { Image, Animated, StyleSheet, ImageStyle } from "react-native";
3
3
 
4
- import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
5
4
  import {
6
5
  useModalAnimationContext,
7
6
  PlayerAnimationStateEnum,
@@ -9,6 +8,7 @@ import {
9
8
  DURATION_TO_MAXIMIZE,
10
9
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
11
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
12
 
13
13
  import { useChangePlayerState } from "./hooks";
14
14
 
@@ -30,10 +30,7 @@ type Props = PropsWithChildren<{
30
30
  export const AnimatedImage = ({ entry, style, imageWidth, docked }: Props) => {
31
31
  const heightAnim = React.useRef(new Animated.Value(imageWidth)).current;
32
32
 
33
- const source = React.useMemo(
34
- () => ({ uri: imageSrcFromMediaItem(entry, undefined) }),
35
- [entry]
36
- );
33
+ const backgroundImageSource = useBackgroundImage(entry);
37
34
 
38
35
  const { minimisedHeight } = useModalAnimationContext();
39
36
 
@@ -70,8 +67,6 @@ export const AnimatedImage = ({ entry, style, imageWidth, docked }: Props) => {
70
67
  };
71
68
  }, [changePlayerState$, minimisedHeight, imageWidth]);
72
69
 
73
- if (!source) return null;
74
-
75
70
  return (
76
71
  <Animated.View
77
72
  style={[
@@ -81,7 +76,7 @@ export const AnimatedImage = ({ entry, style, imageWidth, docked }: Props) => {
81
76
  },
82
77
  ]}
83
78
  >
84
- <Image resizeMode="cover" style={style} source={source} />
79
+ <Image resizeMode="cover" style={style} source={backgroundImageSource} />
85
80
  </Animated.View>
86
81
  );
87
82
  };
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Image, ImageStyle } from "react-native";
3
-
4
- import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
3
+ import { useBackgroundImage } from "@applicaster/zapp-react-native-utils/audioPlayerUtils";
5
4
 
6
5
  type Props = {
7
6
  entry: ZappEntry;
@@ -9,12 +8,9 @@ type Props = {
9
8
  };
10
9
 
11
10
  export const FlexImage = ({ entry, style }: Props) => {
12
- const source = React.useMemo(
13
- () => ({ uri: imageSrcFromMediaItem(entry, undefined) }),
14
- [entry]
15
- );
11
+ const backgroundImageSource = useBackgroundImage(entry);
16
12
 
17
- if (!source) return null;
18
-
19
- return <Image resizeMode="cover" style={style} source={source} />;
13
+ return (
14
+ <Image resizeMode="cover" style={style} source={backgroundImageSource} />
15
+ );
20
16
  };
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import { compose, map, propOr, split, take, trim } from "ramda";
3
2
  import { LayoutChangeEvent, StyleSheet, View } from "react-native";
4
3
 
5
4
  import { TransportInfo as MobileTransportInfo } from "@applicaster/quick-brick-mobile-transport-controls";
@@ -16,6 +15,7 @@ import { NAVBAR_HEIGHT, TABLET_LANDSCAPE } from "../const";
16
15
  import { withDebug } from "../debug";
17
16
  import { useSafeAreaFrame } from "react-native-safe-area-context";
18
17
  import { isSmallTabletHeight } from "../utils";
18
+ import { getPlayerActionButtons } from "@applicaster/zapp-react-native-utils/playerUtils";
19
19
 
20
20
  const styles = StyleSheet.create({
21
21
  container: {
@@ -85,14 +85,8 @@ export const TransportInfo = ({
85
85
  );
86
86
 
87
87
  const actionButtons = React.useMemo(
88
- () =>
89
- compose(
90
- take(2),
91
- map(trim),
92
- split(","),
93
- propOr("", "player_action_buttons")
94
- )(configuration),
95
- [configuration.player_action_buttons]
88
+ () => getPlayerActionButtons(configuration),
89
+ [configuration]
96
90
  );
97
91
 
98
92
  return (
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ModalHeader } from "@applicaster/zapp-react-native-ui-components/Components/ModalComponent/Header";
3
- import { isNil } from "lodash";
3
+ import { isNil } from "@applicaster/zapp-react-native-utils/utils";
4
4
 
5
5
  const formatTime = (milliseconds: number) => {
6
6
  const totalSeconds = Math.floor(milliseconds / 1000);
@@ -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
+ };
@@ -0,0 +1,42 @@
1
+ import { ReactNode, ComponentType } from "react";
2
+ import { PlayNextData } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
3
+ import { ViewStyle } from "react-native";
4
+
5
+ export interface PlayNextOverlayProps {
6
+ playerIsDocked: boolean;
7
+ playerId?: string;
8
+ playNextData: PlayNextData;
9
+ setNextVideoPreloadThresholdPercentage: (percentage: number) => void;
10
+ }
11
+
12
+ export interface PlayerComponentProps {
13
+ ref: React.RefObject<any>;
14
+ listener: Record<string, any>;
15
+ configuration: Record<string, any>;
16
+ style: ViewStyle;
17
+ }
18
+
19
+ export interface AudioPlayerProps {
20
+ style: ViewStyle;
21
+ }
22
+
23
+ export interface PlayerViewBaseProps {
24
+ children?: ReactNode;
25
+ type: "audio" | "video";
26
+ entry: ZappEntry;
27
+ pluginConfiguration: Record<string, any>;
28
+ PlayerComponent: ComponentType<any>;
29
+ playerProps: PlayerComponentProps;
30
+ playNextProps: PlayNextOverlayProps;
31
+ audioPlayerProps: AudioPlayerProps;
32
+ transportControls?: ReactNode;
33
+ inline?: boolean;
34
+ }
35
+
36
+ export interface TvOSPlayerViewProps extends PlayerViewBaseProps {
37
+ nativePlayerIsReady: boolean;
38
+ }
39
+
40
+ export type GenericTVPlayerViewProps = PlayerViewBaseProps;
41
+
42
+ export type TVPlayerViewProps = TvOSPlayerViewProps | GenericTVPlayerViewProps;
@@ -4,8 +4,6 @@
4
4
  import React from "react";
5
5
  import * as R from "ramda";
6
6
 
7
- import { flatten } from "@applicaster/zapp-react-native-utils/utils";
8
-
9
7
  import { findNodeHandle, StyleSheet, View } from "react-native";
10
8
  import TransportControlsMobile from "@applicaster/quick-brick-mobile-transport-controls";
11
9
  import TransportControlsTV from "@applicaster/quick-brick-tv-transport-controls";
@@ -33,7 +31,6 @@ import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
33
31
  import { getAllAccessibilityProps } from "@applicaster/zapp-react-native-utils/configurationUtils";
34
32
  import { PlayNextData } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
35
33
  import { getTargetScreenDataFromEntry } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useTargetScreenData";
36
- import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
37
34
  import {
38
35
  AnimationComponent,
39
36
  ComponentAnimationType,
@@ -42,7 +39,12 @@ import { PlayerAnalyticsManager } from "@applicaster/zapp-react-native-utils/ana
42
39
  import { PlayerAnalyticsTrackerI } from "@applicaster/zapp-react-native-utils/analyticsUtils/playerAnalyticsTracker";
43
40
 
44
41
  import { RNPlayerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/nativePlayerManager";
45
- import { isAudioItem as isAudioItemUtil } from "@applicaster/zapp-react-native-utils/playerUtils";
42
+ import {
43
+ isAudioItem as isAudioItemUtil,
44
+ isInlineTV as isInlineTVUtil,
45
+ } from "@applicaster/zapp-react-native-utils/playerUtils";
46
+
47
+ import { TVPlayerView } from "./PlayerView/TVPlayerView";
46
48
 
47
49
  const styles = StyleSheet.create({
48
50
  container: { flex: 1 },
@@ -53,7 +55,6 @@ const styles = StyleSheet.create({
53
55
  position: "absolute",
54
56
  zIndex: 1,
55
57
  },
56
- audioPlayerSize: { width: "100%", height: "100%" },
57
58
  playerSize: { width: "100%", height: "100%" },
58
59
  });
59
60
 
@@ -64,8 +65,6 @@ const logger = createLogger({
64
65
 
65
66
  const isTvOS = isTvOSPlatform();
66
67
 
67
- const AUDIO_PLAYER_NATIVE_ID = "audio-player-view";
68
-
69
68
  export default class VideoPlayer extends React.Component<
70
69
  QuickBrickPlayer.PlayerProps,
71
70
  QuickBrickPlayer.NativePlayerState
@@ -686,53 +685,6 @@ export default class VideoPlayer extends React.Component<
686
685
  }
687
686
  };
688
687
 
689
- childrenWithExtensions = () => {
690
- const { docked, entry, children } = this.props;
691
-
692
- if (!isTvOS) {
693
- return children;
694
- }
695
-
696
- const output = [];
697
-
698
- // audio-player
699
- if (isAudioItemUtil(entry)) {
700
- const { nativePlayerIsReady } = this.state;
701
-
702
- // we have to wait ready status of native player view, before showing audio_player
703
- if (nativePlayerIsReady) {
704
- output.push(
705
- <View nativeID={AUDIO_PLAYER_NATIVE_ID} key={AUDIO_PLAYER_NATIVE_ID}>
706
- {children}
707
- </View>
708
- );
709
- }
710
- } else {
711
- output.push(children);
712
- }
713
- // audio-player
714
-
715
- // play-next
716
- if (this.getPlayNextData()) {
717
- output.push(
718
- <PlayNextOverlay
719
- key="play-next-overlay"
720
- item={entry}
721
- playerIsDocked={docked}
722
- pluginConfiguration={this.getPluginConfiguration()}
723
- playerId={this.props.playerId}
724
- playNextData={this.getPlayNextData()}
725
- setNextVideoPreloadThresholdPercentage={
726
- this.props.setNextVideoPreloadThresholdPercentage
727
- }
728
- />
729
- );
730
- }
731
- // play-next
732
-
733
- return flatten(output); // prevent possible case with nested array
734
- };
735
-
736
688
  get supportNativeCast() {
737
689
  return this.props.controller.supportNativeCast();
738
690
  }
@@ -799,7 +751,7 @@ export default class VideoPlayer extends React.Component<
799
751
  // TODO: Get screen data more reliable way useCurrentScreenData
800
752
  const screenData = getTargetScreenDataFromEntry(this.props.playableItem);
801
753
 
802
- const isInlineTV = screenData?.ui_components?.length > 0 && isTV();
754
+ const isInlineTV = isInlineTVUtil(screenData);
803
755
 
804
756
  let platformSpecificProps: any = isApplePlatform()
805
757
  ? {
@@ -810,7 +762,7 @@ export default class VideoPlayer extends React.Component<
810
762
  const supportsNativeControls =
811
763
  !!this.props.controller?.supportsNativeControls?.();
812
764
 
813
- const controls = isAppleTV()
765
+ const controls = isTvOS
814
766
  ? (supportsNativeControls && !isInlineTV) || !!this.getPlayNextData()
815
767
  : supportsNativeControls && !this.getPlayNextData();
816
768
 
@@ -857,7 +809,7 @@ export default class VideoPlayer extends React.Component<
857
809
  ),
858
810
  };
859
811
 
860
- if (!isAppleTV()) {
812
+ if (!isTvOS) {
861
813
  // TODO: Move to RN method and remove from props.
862
814
  // Causes tvOS bug: native player passes rate on fast seek,
863
815
  // RN returns it and it breaks playback.
@@ -1139,39 +1091,33 @@ export default class VideoPlayer extends React.Component<
1139
1091
  const renderTVPlayer = () => {
1140
1092
  return (
1141
1093
  <View style={this.takeParentStyle} testID={"player-view"}>
1142
- {!isTvOS && isAudioItem ? (
1143
- <AudioPlayer
1144
- style={getStyle(styles.audioPlayerSize)}
1145
- audio_item={entry}
1146
- plugin_configuration={this.getPluginConfiguration()}
1147
- />
1148
- ) : null}
1149
-
1150
- <this.props.PlayerComponent
1151
- ref={this._assignRoot}
1152
- {...nativeEvents}
1153
- {...nativeProps}
1154
- listener={this.props.listener}
1155
- style={this.takeParentStyle}
1094
+ <TVPlayerView
1095
+ type={isAudioItem ? "audio" : "video"}
1096
+ entry={entry}
1097
+ inline={isInlineTV}
1098
+ transportControls={renderTransportControls(this.takeParentStyle)}
1099
+ PlayerComponent={this.props.PlayerComponent}
1100
+ nativePlayerIsReady={this.state.nativePlayerIsReady}
1156
1101
  pluginConfiguration={this.getPluginConfiguration()}
1157
- controller={this.props.controller}
1102
+ playerProps={{
1103
+ ref: this._assignRoot,
1104
+ ...nativeEvents,
1105
+ ...nativeProps,
1106
+ listener: this.props.listener,
1107
+ style: this.takeParentStyle,
1108
+ controller: this.props.controller,
1109
+ }}
1110
+ audioPlayerProps={{ style: getStyle(styles.playerSize) }}
1111
+ playNextProps={{
1112
+ playerIsDocked: docked,
1113
+ playerId: this.props.playerId,
1114
+ playNextData: this.getPlayNextData(),
1115
+ setNextVideoPreloadThresholdPercentage:
1116
+ this.props.setNextVideoPreloadThresholdPercentage,
1117
+ }}
1158
1118
  >
1159
- {this.childrenWithExtensions()}
1160
- </this.props.PlayerComponent>
1161
-
1162
- {renderTransportControls(this.takeParentStyle)}
1163
- {!isTvOS && (
1164
- <PlayNextOverlay
1165
- item={entry}
1166
- playerIsDocked={docked}
1167
- pluginConfiguration={this.getPluginConfiguration()}
1168
- playerId={this.props.playerId}
1169
- playNextData={this.getPlayNextData()}
1170
- setNextVideoPreloadThresholdPercentage={
1171
- this.props.setNextVideoPreloadThresholdPercentage
1172
- }
1173
- />
1174
- )}
1119
+ {this.props.children}
1120
+ </TVPlayerView>
1175
1121
  </View>
1176
1122
  );
1177
1123
  };