@applicaster/quick-brick-player 13.0.5 → 13.0.6-alpha.4144634915

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.
@@ -1,12 +1,12 @@
1
+ /* eslint-disable react-native/no-inline-styles */
1
2
  /* eslint-disable @typescript-eslint/no-use-before-define */
2
3
  /* eslint-disable react-native/no-color-literals */
3
4
 
4
5
  import React from "react";
5
6
  import * as R from "ramda";
6
7
 
7
- import { flatten } from "@applicaster/zapp-react-native-utils/utils";
8
+ import { findNodeHandle, StyleSheet, View, Dimensions } from "react-native";
8
9
 
9
- import { findNodeHandle, StyleSheet, View } from "react-native";
10
10
  import TransportControlsMobile from "@applicaster/quick-brick-mobile-transport-controls";
11
11
  import TransportControlsTV from "@applicaster/quick-brick-tv-transport-controls";
12
12
 
@@ -19,7 +19,10 @@ import {
19
19
  isWeb,
20
20
  } from "@applicaster/zapp-react-native-utils/reactUtils";
21
21
 
22
- import { PlayerWrapper } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
22
+ import {
23
+ PlayerDetails,
24
+ PlayerWrapper,
25
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
23
26
 
24
27
  import { PlayNextOverlay } from "./PlayNextOverlay";
25
28
  import { PlayerImageBackground } from "@applicaster/zapp-react-native-ui-components/Components/PlayerImageBackground";
@@ -33,19 +36,20 @@ import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
33
36
  import { getAllAccessibilityProps } from "@applicaster/zapp-react-native-utils/configurationUtils";
34
37
  import { PlayNextData } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
35
38
  import { getTargetScreenDataFromEntry } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useTargetScreenData";
36
- import {
37
- AnimationComponent,
38
- ComponentAnimationType,
39
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
40
39
  import { PlayerAnalyticsManager } from "@applicaster/zapp-react-native-utils/analyticsUtils/PlayerAnalyticsManager";
41
40
  import { PlayerAnalyticsTrackerI } from "@applicaster/zapp-react-native-utils/analyticsUtils/playerAnalyticsTracker";
42
41
 
43
42
  import { RNPlayerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/nativePlayerManager";
44
43
  import {
44
+ getTabletWidth,
45
45
  isAudioItem as isAudioItemUtil,
46
46
  isInlineTV as isInlineTVUtil,
47
47
  } from "@applicaster/zapp-react-native-utils/playerUtils";
48
48
 
49
+ import PlayerModal, { VideoPlayerModal } from "./PlayerModal";
50
+ import { DockedControls } from "./AudioLayer/Layout/DockedControls";
51
+ import { FlexImage } from "./AudioLayer/Layout/PlayerImage/FlexImage";
52
+
49
53
  const styles = StyleSheet.create({
50
54
  container: { flex: 1 },
51
55
  playerContainerBlack: { backgroundColor: DEFAULT_COLORS.black },
@@ -57,6 +61,7 @@ const styles = StyleSheet.create({
57
61
  },
58
62
  audioPlayerSize: { width: "100%", height: "100%" },
59
63
  playerSize: { width: "100%", height: "100%" },
64
+ flexImage: { height: "100%", aspectRatio: 1, flex: -1 },
60
65
  });
61
66
 
62
67
  const logger = createLogger({
@@ -68,6 +73,15 @@ const isTvOS = isTvOSPlatform();
68
73
 
69
74
  const AUDIO_PLAYER_NATIVE_ID = "audio-player-view";
70
75
 
76
+ const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
77
+
78
+ const getScreenAspectRatio = () => {
79
+ const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
80
+ const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
81
+
82
+ return longEdge / shortEdge;
83
+ };
84
+
71
85
  export default class VideoPlayer extends React.Component<
72
86
  QuickBrickPlayer.PlayerProps,
73
87
  QuickBrickPlayer.NativePlayerState
@@ -1021,120 +1035,163 @@ export default class VideoPlayer extends React.Component<
1021
1035
  pip: this.state.piped,
1022
1036
  },
1023
1037
  configuration: this.getPluginConfiguration(),
1024
- fullscreen: fullscreen,
1025
- isTabletPortrait: isTabletPortrait,
1038
+ isTabletPortrait,
1026
1039
  playNextData: this.getPlayNextData(),
1027
1040
  };
1028
1041
 
1029
- const containerStyle = { flex: 1 };
1030
-
1031
1042
  const backgroundImageKey =
1032
1043
  this.getPluginConfiguration()?.player_preview_image_key;
1033
1044
 
1034
1045
  const shouldRenderNativePlayer =
1035
1046
  !this.props.isCasting || this.supportNativeCast;
1036
1047
 
1048
+ const aspectRatio =
1049
+ !inline && isModal && !this.state.piped ? getScreenAspectRatio() : 16 / 9;
1050
+
1037
1051
  const renderMobilePlayer = () => {
1038
1052
  return isFullScreenAudioPlayer && isAudioItem ? (
1039
1053
  // Ensure the View remains in the native hierarchy for proper rendering and interaction
1040
- <View collapsable={false} style={containerStyle}>
1041
- {shouldRenderNativePlayer ? (
1042
- <this.props.PlayerComponent
1043
- ref={this._assignRoot}
1044
- {...nativeEvents}
1045
- {...nativeProps}
1046
- listener={this.props.listener}
1047
- />
1048
- ) : null}
1049
- <AudioPlayerWrapper {...sharedWrapperViewProps} />
1050
- </View>
1054
+ <PlayerModal
1055
+ content={
1056
+ <View collapsable={false} style={styles.container}>
1057
+ {shouldRenderNativePlayer ? (
1058
+ <this.props.PlayerComponent
1059
+ ref={this._assignRoot}
1060
+ {...nativeEvents}
1061
+ {...nativeProps}
1062
+ listener={this.props.listener}
1063
+ />
1064
+ ) : null}
1065
+ <AudioPlayerWrapper {...sharedWrapperViewProps} />
1066
+ </View>
1067
+ }
1068
+ collapsedContent={
1069
+ <View style={styles.container}>
1070
+ <DockedControls
1071
+ entry={entry}
1072
+ aspectRatio={1}
1073
+ layoutState={sharedWrapperViewProps.layoutState}
1074
+ playNextData={sharedWrapperViewProps.playNextData}
1075
+ ImageComponent={
1076
+ <FlexImage entry={entry} style={styles.flexImage} />
1077
+ }
1078
+ />
1079
+ </View>
1080
+ }
1081
+ />
1051
1082
  ) : (
1052
- <PlayerWrapper {...sharedWrapperViewProps}>
1053
- {(playerDimensions) => {
1054
- const shouldRenderBackground =
1055
- !R.isNil(backgroundImageKey) &&
1056
- backgroundImageKey.length > 0 &&
1057
- !this.onVideoLoadCalled &&
1058
- !this.state.isAd;
1059
-
1060
- return (
1061
- <View style={styles.container}>
1062
- <View style={[playerContainerStyles, playerDimensions]}>
1063
- {isAudioItem ? (
1064
- <AnimationComponent
1065
- animationType={ComponentAnimationType.player}
1066
- additionalData={{
1067
- ...playerDimensions,
1068
- inlineAudioPlayer: true,
1069
- }}
1070
- style={getStyle(playerDimensions)}
1071
- >
1072
- <AudioPlayer
1073
- style={
1074
- isTV()
1075
- ? getStyle(playerDimensions)
1076
- : styles.playerSize
1083
+ <VideoPlayerModal
1084
+ enabled={!!isModal && !fullscreen}
1085
+ isTabletPortrait={isTabletPortrait}
1086
+ aspectRatio={aspectRatio}
1087
+ pip={this.state.piped}
1088
+ fullscreen={fullscreen}
1089
+ style={{
1090
+ tabletLandscapeWidth: getTabletWidth(
1091
+ this.getPluginConfiguration().tablet_landscape_sidebar_width,
1092
+ style
1093
+ ),
1094
+ width: style.width,
1095
+ height: style.height,
1096
+ }}
1097
+ content={(_opacityAnim) => (
1098
+ <PlayerWrapper
1099
+ {...sharedWrapperViewProps}
1100
+ playerContent={(playerDimensions) => {
1101
+ const shouldRenderBackground =
1102
+ !R.isNil(backgroundImageKey) &&
1103
+ backgroundImageKey.length > 0 &&
1104
+ !this.onVideoLoadCalled &&
1105
+ !this.state.isAd;
1106
+
1107
+ return (
1108
+ <View style={styles.container}>
1109
+ <View style={[playerContainerStyles, playerDimensions]}>
1110
+ {isAudioItem ? (
1111
+ <AudioPlayer
1112
+ style={
1113
+ isTV()
1114
+ ? getStyle(playerDimensions)
1115
+ : styles.playerSize
1116
+ }
1117
+ audio_item={entry}
1118
+ plugin_configuration={this.getPluginConfiguration()}
1119
+ />
1120
+ ) : null}
1121
+
1122
+ {shouldRenderBackground ? (
1123
+ <PlayerImageBackground
1124
+ imageKey={backgroundImageKey}
1125
+ configuration={this.getPluginConfiguration()}
1126
+ entry={entry}
1127
+ style={getBackgroundImageStyle(playerDimensions)}
1128
+ />
1129
+ ) : null}
1130
+
1131
+ {shouldRenderNativePlayer ? (
1132
+ <View style={getStyle(playerDimensions)}>
1133
+ <this.props.PlayerComponent
1134
+ ref={this._assignRoot}
1135
+ {...nativeEvents}
1136
+ {...nativeProps}
1137
+ listener={this.props.listener}
1138
+ style={
1139
+ isTV()
1140
+ ? getStyle(playerDimensions)
1141
+ : styles.playerSize
1142
+ }
1143
+ pluginConfiguration={this.getPluginConfiguration()}
1144
+ controller={this.props.controller}
1145
+ >
1146
+ {this.props.children}
1147
+ </this.props.PlayerComponent>
1148
+ </View>
1149
+ ) : null}
1150
+ </View>
1151
+
1152
+ {renderTransportControls(playerDimensions)}
1153
+ {!this.state.piped && (
1154
+ <PlayNextOverlay
1155
+ item={entry}
1156
+ playerIsDocked={docked}
1157
+ pluginConfiguration={this.getPluginConfiguration()}
1158
+ playerId={this.props.playerId}
1159
+ playNextData={this.getPlayNextData()}
1160
+ setNextVideoPreloadThresholdPercentage={
1161
+ this.props.setNextVideoPreloadThresholdPercentage
1077
1162
  }
1078
- audio_item={entry}
1079
- plugin_configuration={this.getPluginConfiguration()}
1080
1163
  />
1081
- </AnimationComponent>
1082
- ) : null}
1083
-
1084
- {shouldRenderBackground ? (
1085
- <PlayerImageBackground
1086
- imageKey={backgroundImageKey}
1087
- configuration={this.getPluginConfiguration()}
1088
- entry={entry}
1089
- style={getBackgroundImageStyle(playerDimensions)}
1090
- />
1091
- ) : null}
1092
-
1093
- {shouldRenderNativePlayer ? (
1094
- <AnimationComponent
1095
- animationType={ComponentAnimationType.player}
1096
- additionalData={{
1097
- ...playerDimensions,
1098
- disableAnimatedComponent: isAudioItem,
1099
- }}
1100
- style={getStyle(playerDimensions)}
1101
- >
1102
- <this.props.PlayerComponent
1103
- ref={this._assignRoot}
1104
- {...nativeEvents}
1105
- {...nativeProps}
1106
- listener={this.props.listener}
1107
- style={
1108
- isTV()
1109
- ? getStyle(playerDimensions)
1110
- : styles.playerSize
1111
- }
1112
- pluginConfiguration={this.getPluginConfiguration()}
1113
- controller={this.props.controller}
1114
- >
1115
- {this.props.children}
1116
- </this.props.PlayerComponent>
1117
- </AnimationComponent>
1118
- ) : null}
1119
- </View>
1120
-
1121
- {renderTransportControls(playerDimensions)}
1122
- {!this.state.piped && (
1123
- <PlayNextOverlay
1124
- item={entry}
1125
- playerIsDocked={docked}
1126
- pluginConfiguration={this.getPluginConfiguration()}
1127
- playerId={this.props.playerId}
1128
- playNextData={this.getPlayNextData()}
1129
- setNextVideoPreloadThresholdPercentage={
1130
- this.props.setNextVideoPreloadThresholdPercentage
1131
- }
1132
- />
1133
- )}
1164
+ )}
1165
+ </View>
1166
+ );
1167
+ }}
1168
+ />
1169
+ )}
1170
+ extraContent={(_opacityAnim) => (
1171
+ <PlayerDetails
1172
+ configuration={this.getPluginConfiguration()}
1173
+ style={{ flex: 1 }}
1174
+ entry={entry}
1175
+ isTabletLandscape={!isTabletPortrait}
1176
+ inline={inline}
1177
+ docked={docked}
1178
+ isModal={isModal}
1179
+ pip={this.state.piped}
1180
+ />
1181
+ )}
1182
+ collapsedContent={(_opacityAnim) =>
1183
+ this.state.piped ? null : (
1184
+ <View style={styles.container}>
1185
+ <DockedControls
1186
+ entry={entry}
1187
+ aspectRatio={aspectRatio}
1188
+ layoutState={sharedWrapperViewProps.layoutState}
1189
+ playNextData={sharedWrapperViewProps.playNextData}
1190
+ />
1134
1191
  </View>
1135
- );
1136
- }}
1137
- </PlayerWrapper>
1192
+ )
1193
+ }
1194
+ />
1138
1195
  );
1139
1196
  };
1140
1197