@applicaster/quick-brick-player 13.0.0-rc.12 → 13.0.0-rc.121

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.
Files changed (44) hide show
  1. package/package.json +27 -14
  2. package/src/CellPlayer/Assets/AssetsComponent.tsx +17 -3
  3. package/src/Player/AudioLayer/AudioDescription.tsx +107 -68
  4. package/src/Player/AudioLayer/AudioPlayerWrapper.tsx +205 -281
  5. package/src/Player/AudioLayer/Layout/Controls/VerticalGutter.tsx +45 -0
  6. package/src/Player/AudioLayer/Layout/Controls/index.tsx +320 -0
  7. package/src/Player/AudioLayer/Layout/{defaultLayoutsConts.ts → Controls/utils.ts} +7 -25
  8. package/src/Player/AudioLayer/Layout/Debug/index.tsx +55 -0
  9. package/src/Player/AudioLayer/Layout/{DockedLayout.tsx → DockedControls/index.tsx} +77 -81
  10. package/src/Player/AudioLayer/Layout/MobileLayout.tsx +230 -0
  11. package/src/Player/AudioLayer/Layout/PlayerImage/AnimatedImage.tsx +70 -0
  12. package/src/Player/AudioLayer/Layout/PlayerImage/FlexImage.tsx +20 -0
  13. package/src/Player/AudioLayer/Layout/PlayerImage/index.tsx +108 -0
  14. package/src/Player/AudioLayer/Layout/PlayerImage/styles.ts +36 -0
  15. package/src/Player/AudioLayer/Layout/TabletLandscapeLayout.tsx +220 -0
  16. package/src/Player/AudioLayer/Layout/TabletPortraitLayout.tsx +223 -0
  17. package/src/Player/AudioLayer/Layout/TransportInfo/index.tsx +128 -0
  18. package/src/Player/AudioLayer/Layout/VerticalGutter/index.tsx +8 -0
  19. package/src/Player/AudioLayer/Layout/const.ts +26 -0
  20. package/src/Player/AudioLayer/Layout/debug.ts +6 -0
  21. package/src/Player/AudioLayer/Layout/hooks/index.ts +5 -0
  22. package/src/Player/AudioLayer/Layout/hooks/useMobileLayoutImageSize.ts +14 -0
  23. package/src/Player/AudioLayer/Layout/hooks/useTabletLayoutImageSize.ts +105 -0
  24. package/src/Player/AudioLayer/Layout/hooks/useTransportInfoHeight.ts +54 -0
  25. package/src/Player/AudioLayer/Layout/index.tsx +21 -48
  26. package/src/Player/AudioLayer/Layout/types.ts +7 -0
  27. package/src/Player/AudioLayer/Layout/utils.ts +7 -0
  28. package/src/Player/AudioLayer/SleepTimerManager.ts +119 -0
  29. package/src/Player/AudioLayer/SpeedManager.ts +52 -0
  30. package/src/Player/AudioLayer/utils.ts +27 -0
  31. package/src/Player/Const/sleepTimerOptions.ts +39 -0
  32. package/src/Player/Const/speedOptions.ts +4 -0
  33. package/src/Player/Utils/Utils.ts +0 -5
  34. package/src/Player/Utils/index.tsx +117 -0
  35. package/src/Player/hooks/useIsCasting.tsx +57 -0
  36. package/src/Player/index.tsx +39 -22
  37. package/src/QuickBrickPlayer.tsx +3 -0
  38. package/src/Player/AudioLayer/Layout/DefaultLayout.tsx +0 -452
  39. package/src/Player/AudioLayer/LinearGradient/LinearGradientProxy.ts +0 -3
  40. package/src/Player/AudioLayer/LinearGradient/LinearGradientProxy.web.ts +0 -3
  41. package/src/Player/AudioLayer/LinearGradient/index.ts +0 -1
  42. package/src/Player/AudioLayer/MagicBG/index.tsx +0 -155
  43. package/src/Player/Helpers/VideoResizeMode.ts +0 -7
  44. package/src/utils/utils.ts +0 -25
@@ -1 +1,118 @@
1
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
2
+
1
3
  export * from "./Utils";
4
+
5
+ export const getBottomSheetModalIconProps = (theme) => ({
6
+ height: theme["audio_modal_bottom_sheet_item_icon_height"],
7
+ width: theme["audio_modal_bottom_sheet_item_icon_width"],
8
+ marginBottom: theme["audio_modal_bottom_sheet_item_icon_margin_bottom"],
9
+ marginLeft: theme["audio_modal_bottom_sheet_item_icon_margin_left"],
10
+ marginRight: theme["audio_modal_bottom_sheet_item_icon_margin_right"],
11
+ marginTop: theme["audio_modal_bottom_sheet_item_icon_margin_top"],
12
+ flavour: theme["modal_bottom_sheet_item_icon_flavour"],
13
+ });
14
+
15
+ export const getBottomSheetModalLabelProps = (theme, width: number) => {
16
+ const {
17
+ audio_modal_bottom_sheet_item_label_android_letter_spacing,
18
+ audio_modal_bottom_sheet_item_label_ios_letter_spacing,
19
+ audio_modal_bottom_sheet_item_label_family_ios_font_selector,
20
+ audio_modal_bottom_sheet_item_label_family_android_font_selector,
21
+ audio_modal_bottom_sheet_item_label_focus_font_color,
22
+ audio_modal_bottom_sheet_item_label_font_color,
23
+ audio_modal_bottom_sheet_item_label_selected_font_color,
24
+ audio_modal_bottom_sheet_item_label_hover_selected_font_color,
25
+ audio_modal_bottom_sheet_item_label_font_size,
26
+ audio_modal_bottom_sheet_item_label_line_height,
27
+ audio_modal_bottom_sheet_item_label_margin_bottom,
28
+ audio_modal_bottom_sheet_item_label_margin_top,
29
+ audio_modal_bottom_sheet_item_label_margin_left,
30
+ audio_modal_bottom_sheet_item_label_margin_right,
31
+ audio_modal_bottom_sheet_item_label_transform,
32
+ audio_modal_bottom_sheet_item_icon_width,
33
+ audio_modal_bottom_sheet_item_icon_margin_left,
34
+ audio_modal_bottom_sheet_item_icon_margin_right,
35
+ audio_modal_bottom_sheet_item_margin_left,
36
+ audio_modal_bottom_sheet_item_margin_right,
37
+ audio_modal_bottom_sheet_item_padding_left,
38
+ audio_modal_bottom_sheet_item_padding_right,
39
+ } = theme;
40
+
41
+ const maxWidth =
42
+ width -
43
+ (audio_modal_bottom_sheet_item_icon_width +
44
+ audio_modal_bottom_sheet_item_icon_margin_left +
45
+ audio_modal_bottom_sheet_item_icon_margin_right +
46
+ audio_modal_bottom_sheet_item_margin_left +
47
+ audio_modal_bottom_sheet_item_margin_right +
48
+ audio_modal_bottom_sheet_item_padding_left +
49
+ audio_modal_bottom_sheet_item_padding_right);
50
+
51
+ return {
52
+ fontFamily: platformSelect({
53
+ ios: audio_modal_bottom_sheet_item_label_family_ios_font_selector,
54
+ android: audio_modal_bottom_sheet_item_label_family_android_font_selector,
55
+ }),
56
+ letterSpacing: platformSelect({
57
+ ios: audio_modal_bottom_sheet_item_label_ios_letter_spacing,
58
+ android: audio_modal_bottom_sheet_item_label_android_letter_spacing,
59
+ }),
60
+ fontSize: audio_modal_bottom_sheet_item_label_font_size,
61
+ color: audio_modal_bottom_sheet_item_label_font_color,
62
+ focusColor: audio_modal_bottom_sheet_item_label_focus_font_color,
63
+ hoverSelectedColor:
64
+ audio_modal_bottom_sheet_item_label_hover_selected_font_color,
65
+ selectedColor: audio_modal_bottom_sheet_item_label_selected_font_color,
66
+ lineHeight: audio_modal_bottom_sheet_item_label_line_height,
67
+ marginBottom: audio_modal_bottom_sheet_item_label_margin_bottom,
68
+ marginTop: audio_modal_bottom_sheet_item_label_margin_top,
69
+ marginLeft: audio_modal_bottom_sheet_item_label_margin_left,
70
+ marginRight: audio_modal_bottom_sheet_item_label_margin_right,
71
+ transform: audio_modal_bottom_sheet_item_label_transform,
72
+ maxWidth,
73
+ };
74
+ };
75
+
76
+ export const getBottomSheetModalItemProps = (theme, width: number) => {
77
+ const {
78
+ audio_modal_bottom_sheet_item_background_color,
79
+ audio_modal_bottom_sheet_item_focus_background_color,
80
+ audio_modal_bottom_sheet_item_selected_background_color,
81
+ audio_modal_bottom_sheet_item_focused_selected_background_color,
82
+ audio_modal_bottom_sheet_item_corner_radius,
83
+ audio_modal_bottom_sheet_item_margin_bottom,
84
+ audio_modal_bottom_sheet_item_margin_left,
85
+ audio_modal_bottom_sheet_item_margin_right,
86
+ audio_modal_bottom_sheet_item_margin_top,
87
+ audio_modal_bottom_sheet_item_padding_bottom,
88
+ audio_modal_bottom_sheet_item_padding_left,
89
+ audio_modal_bottom_sheet_item_padding_right,
90
+ audio_modal_bottom_sheet_item_padding_top,
91
+ } = theme;
92
+
93
+ return {
94
+ backgroundColor: audio_modal_bottom_sheet_item_background_color,
95
+ focusedBackgroundColor:
96
+ audio_modal_bottom_sheet_item_focus_background_color,
97
+ selectedBackgroundColor:
98
+ audio_modal_bottom_sheet_item_selected_background_color,
99
+ focusedSelectedBackgroundColor:
100
+ audio_modal_bottom_sheet_item_focused_selected_background_color,
101
+ borderRadius: audio_modal_bottom_sheet_item_corner_radius,
102
+ marginBottom: audio_modal_bottom_sheet_item_margin_bottom,
103
+ marginTop: audio_modal_bottom_sheet_item_margin_top,
104
+ marginLeft: audio_modal_bottom_sheet_item_margin_left,
105
+ marginRight: audio_modal_bottom_sheet_item_margin_right,
106
+ paddingTop: audio_modal_bottom_sheet_item_padding_top,
107
+ paddingBottom: audio_modal_bottom_sheet_item_padding_bottom,
108
+ paddingRight: audio_modal_bottom_sheet_item_padding_right,
109
+ paddingLeft: audio_modal_bottom_sheet_item_padding_left,
110
+ maxWidth: width,
111
+ };
112
+ };
113
+
114
+ export const getBottomSheetModalSelectedItemIcon = (theme) =>
115
+ theme["audio_modal_bottom_sheet_item_selected_icon"] || null;
116
+
117
+ export const getBottomSheetModalDefaultItemIcon = (theme) =>
118
+ theme["audio_modal_bottom_sheet_item_default_icon"] || null;
@@ -0,0 +1,57 @@
1
+ import React from "react";
2
+ import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
3
+ import { useAppState } from "@applicaster/zapp-react-native-utils/reactHooks/app";
4
+ import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
5
+
6
+ const CHROMECAST_IDENTIFIER = "quick-brick-chromecast-action";
7
+
8
+ const fakeEntry: any = {
9
+ title: "Chromecast use is casting fake entry",
10
+ id: "quick-brick-use-is-casting-fake-entry",
11
+ };
12
+
13
+ /**
14
+ * Returns the cast action state connection status, does not update when app is in background on Apple platforms
15
+ * On other platforms, it continues to check the cast action state even when the app is in background
16
+ */
17
+ export const useIsCasting = () => {
18
+ const actionContext = useActions(CHROMECAST_IDENTIFIER);
19
+ const appState = useAppState();
20
+ const isAppInForeground = appState === "active";
21
+ const shouldOnlyUpdateInForeground = isApplePlatform();
22
+
23
+ const [castActionState, setCastActionState] = React.useState(
24
+ !actionContext ? null : actionContext.initialEntryState(fakeEntry)
25
+ );
26
+
27
+ React.useEffect(() => {
28
+ if (!shouldOnlyUpdateInForeground || isAppInForeground) {
29
+ if (actionContext && castActionState === null) {
30
+ setCastActionState(actionContext.initialEntryState(fakeEntry));
31
+ }
32
+ }
33
+ }, [
34
+ actionContext,
35
+ setCastActionState,
36
+ isAppInForeground,
37
+ shouldOnlyUpdateInForeground,
38
+ ]);
39
+
40
+ React.useEffect(() => {
41
+ if (typeof actionContext?.addListener === "function") {
42
+ return actionContext?.addListener(String(fakeEntry.id), (state) => {
43
+ // Only check foreground state on Apple platforms
44
+ if (!shouldOnlyUpdateInForeground || isAppInForeground) {
45
+ setCastActionState(state);
46
+ }
47
+ });
48
+ }
49
+ }, [
50
+ setCastActionState,
51
+ actionContext,
52
+ isAppInForeground,
53
+ shouldOnlyUpdateInForeground,
54
+ ]);
55
+
56
+ return !!castActionState?.connected;
57
+ };
@@ -74,6 +74,7 @@ export default class VideoPlayer extends React.Component<
74
74
  state: QuickBrickPlayer.NativePlayerState = {
75
75
  audioTrackId: null,
76
76
  textTrackId: null,
77
+ isCasting: this.props.isCasting,
77
78
 
78
79
  // TODO: Can be deleted, on controller logic
79
80
  isAd: false,
@@ -698,6 +699,10 @@ export default class VideoPlayer extends React.Component<
698
699
  ];
699
700
  };
700
701
 
702
+ get supportNativeCast() {
703
+ return this.props.controller.supportNativeCast();
704
+ }
705
+
701
706
  render() {
702
707
  const {
703
708
  docked,
@@ -710,18 +715,15 @@ export default class VideoPlayer extends React.Component<
710
715
  muted,
711
716
  style,
712
717
  castAction,
713
- controller,
714
718
  startComponentsAnimation,
715
719
  } = this.props;
716
720
 
717
- const supportNativeCast = controller.supportNativeCast();
718
-
719
721
  const { audioTrackId, keyEvent, paused, seek, textTrackId, rate } =
720
722
  this.state;
721
723
 
722
724
  const isAudioItem =
723
725
  entry?.content?.type?.includes?.("audio") ||
724
- entry?.type?.value === "audio";
726
+ entry?.type?.value?.includes?.("audio");
725
727
 
726
728
  const getStyle = (dimensions) => {
727
729
  const generalStyles = isAudioItem ? styles.audio : styles.video;
@@ -791,8 +793,13 @@ export default class VideoPlayer extends React.Component<
791
793
  controls: shouldUseNativeControls,
792
794
  };
793
795
 
796
+ const isFullScreenAudioPlayer =
797
+ this.getPluginConfiguration()?.["full_screen_audio_player"] || false;
798
+
799
+ const isAudioPlayer = isFullScreenAudioPlayer && isAudioItem;
800
+
794
801
  const pictureInPictureEnabled =
795
- this.props.pluginConfiguration?.pictureInPictureEnabled;
802
+ this.props.pluginConfiguration?.pictureInPictureEnabled && !isAudioPlayer;
796
803
 
797
804
  const nativeProps = {
798
805
  entry, // Must be passed first in list
@@ -806,7 +813,6 @@ export default class VideoPlayer extends React.Component<
806
813
  nowPlayingEnabled,
807
814
  paused,
808
815
  seek,
809
- rate,
810
816
  textTrackId,
811
817
  liveSeekingEnabled,
812
818
  liveCatchUpEnabled,
@@ -817,7 +823,14 @@ export default class VideoPlayer extends React.Component<
817
823
  accessibilityProps: getAllAccessibilityProps(
818
824
  this.getPluginConfiguration()
819
825
  ),
820
- }; // rate temporary removed, because of bug with subtitles
826
+ };
827
+
828
+ if (!isAppleTV()) {
829
+ // TODO: Move to RN method and remove from props.
830
+ // Causes tvOS bug: native player passes rate on fast seek,
831
+ // RN returns it and it breaks playback.
832
+ nativeProps.rate = rate;
833
+ }
821
834
 
822
835
  if (
823
836
  this.isReactNativeMethodsSupported() &&
@@ -918,8 +931,8 @@ export default class VideoPlayer extends React.Component<
918
931
  const playerContainerStyles = isApplePlatform()
919
932
  ? styles.playerContainerBlack
920
933
  : isTV() && isAudioItem
921
- ? styles.playerContainerTransparent
922
- : styles.playerContainerBlack;
934
+ ? styles.playerContainerTransparent
935
+ : styles.playerContainerBlack;
923
936
 
924
937
  const isInline = () => {
925
938
  if (isTV()) {
@@ -960,9 +973,6 @@ export default class VideoPlayer extends React.Component<
960
973
  ) : null;
961
974
  };
962
975
 
963
- const isFullScreenAudioPlayer =
964
- this.getPluginConfiguration()?.["full_screen_audio_player"] || false;
965
-
966
976
  const sharedWrapperViewProps = {
967
977
  style,
968
978
  entry,
@@ -987,17 +997,21 @@ export default class VideoPlayer extends React.Component<
987
997
  const backgroundImageKey =
988
998
  this.getPluginConfiguration()?.player_preview_image_key;
989
999
 
1000
+ const shouldRenderNativePlayer =
1001
+ !this.props.isCasting || this.supportNativeCast;
1002
+
990
1003
  const renderMobilePlayer = () => {
991
1004
  return isFullScreenAudioPlayer && isAudioItem ? (
992
- <View style={containerStyle}>
993
- {(!castAction?.state?.connected || supportNativeCast) && (
1005
+ // Ensure the View remains in the native hierarchy for proper rendering and interaction
1006
+ <View collapsable={false} style={containerStyle}>
1007
+ {shouldRenderNativePlayer ? (
994
1008
  <this.props.PlayerComponent
995
1009
  ref={this._assignRoot}
996
1010
  {...nativeEvents}
997
1011
  {...nativeProps}
998
1012
  listener={this.props.listener}
999
1013
  />
1000
- )}
1014
+ ) : null}
1001
1015
  <AudioPlayerWrapper {...sharedWrapperViewProps} />
1002
1016
  </View>
1003
1017
  ) : (
@@ -1012,7 +1026,7 @@ export default class VideoPlayer extends React.Component<
1012
1026
  return (
1013
1027
  <View style={styles.container}>
1014
1028
  <View style={[playerContainerStyles, playerDimensions]}>
1015
- {isAudioItem && (
1029
+ {isAudioItem ? (
1016
1030
  <AnimationComponent
1017
1031
  animationType={ComponentAnimationType.player}
1018
1032
  additionalData={{
@@ -1031,21 +1045,24 @@ export default class VideoPlayer extends React.Component<
1031
1045
  plugin_configuration={this.getPluginConfiguration()}
1032
1046
  />
1033
1047
  </AnimationComponent>
1034
- )}
1048
+ ) : null}
1035
1049
 
1036
- {shouldRenderBackground && (
1050
+ {shouldRenderBackground ? (
1037
1051
  <PlayerImageBackground
1038
1052
  imageKey={backgroundImageKey}
1039
1053
  configuration={this.getPluginConfiguration()}
1040
1054
  entry={entry}
1041
1055
  style={getBackgroundImageStyle(playerDimensions)}
1042
1056
  />
1043
- )}
1057
+ ) : null}
1044
1058
 
1045
- {(!castAction?.state?.connected || supportNativeCast) && (
1059
+ {shouldRenderNativePlayer ? (
1046
1060
  <AnimationComponent
1047
1061
  animationType={ComponentAnimationType.player}
1048
- additionalData={playerDimensions}
1062
+ additionalData={{
1063
+ ...playerDimensions,
1064
+ disableAnimatedComponent: isAudioItem,
1065
+ }}
1049
1066
  style={getStyle(playerDimensions)}
1050
1067
  >
1051
1068
  <this.props.PlayerComponent
@@ -1064,7 +1081,7 @@ export default class VideoPlayer extends React.Component<
1064
1081
  {this.childrenWithPlayNext()}
1065
1082
  </this.props.PlayerComponent>
1066
1083
  </AnimationComponent>
1067
- )}
1084
+ ) : null}
1068
1085
  </View>
1069
1086
 
1070
1087
  {renderTransportControls(playerDimensions)}
@@ -5,6 +5,7 @@ import Player from "./Player";
5
5
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
6
6
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
7
7
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
8
+ import { useIsCasting } from "./Player/hooks/useIsCasting";
8
9
 
9
10
  const CHROMECAST_IDENTIFIER = "quick-brick-chromecast-action";
10
11
 
@@ -24,6 +25,7 @@ const QuickBrickPlayerComponent = (
24
25
  }, [props.PlayerComponent]);
25
26
 
26
27
  const castAction = useActions(CHROMECAST_IDENTIFIER);
28
+ const isCasting = useIsCasting();
27
29
 
28
30
  const isModal = Boolean(props?.isModal);
29
31
  const isScreenDisabled = !controller?.isFullScreenSupported() || !isModal;
@@ -48,6 +50,7 @@ const QuickBrickPlayerComponent = (
48
50
  {...props}
49
51
  ref={ref}
50
52
  castAction={!props?.disableCastAction && castAction}
53
+ isCasting={isCasting}
51
54
  PlayerComponent={props.PlayerComponent}
52
55
  openPiP={openPiP}
53
56
  closePiP={closePiP}