@applicaster/quick-brick-player 15.0.0-alpha.6141436051 → 15.0.0-alpha.9361645236

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": "15.0.0-alpha.6141436051",
3
+ "version": "15.0.0-alpha.9361645236",
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-alpha.6141436051",
39
- "@applicaster/quick-brick-tv-transport-controls": "15.0.0-rc.15",
40
- "@applicaster/zapp-react-native-tvos-app": "15.0.0-alpha.6141436051",
41
- "@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.6141436051",
42
- "@applicaster/zapp-react-native-utils": "15.0.0-alpha.6141436051",
38
+ "@applicaster/quick-brick-mobile-transport-controls": "15.0.0-alpha.9361645236",
39
+ "@applicaster/quick-brick-tv-transport-controls": "15.0.0-alpha.9361645236",
40
+ "@applicaster/zapp-react-native-tvos-app": "15.0.0-alpha.9361645236",
41
+ "@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.9361645236",
42
+ "@applicaster/zapp-react-native-utils": "15.0.0-alpha.9361645236",
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: {}) => stylesObj?.[key] ?? null;
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 progresBarLayoutState = React.useMemo(
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={progresBarLayoutState}
279
+ layoutState={progressBarLayoutState}
279
280
  onPlayerSeek={onPlayerSeek}
280
281
  playerState={playerState}
281
282
  docked
@@ -6,7 +6,7 @@ import { useStyles } from "./styles";
6
6
  import { useVideoModalState } from "./hooks";
7
7
  import { MODAL_COLLAPSE_RATIO, MODAL_RADIUS } from "./consts";
8
8
  import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
9
- import { getWindowHeight } from "./utils";
9
+ import { getScreenHeight, getWindowHeight } from "./utils";
10
10
 
11
11
  type AnimatedModalProps = {
12
12
  content?: ReactElement;
@@ -31,6 +31,7 @@ export function AnimatedModal({
31
31
 
32
32
  const WINDOW_HEIGHT = getWindowHeight();
33
33
  const heightAboveMinimised = WINDOW_HEIGHT - collapsedHeight;
34
+ const screenHeight = getScreenHeight();
34
35
 
35
36
  const MODAL_COLLAPSE_START = WINDOW_HEIGHT * MODAL_COLLAPSE_RATIO;
36
37
 
@@ -63,7 +64,7 @@ export function AnimatedModal({
63
64
  borderTopLeftRadius: borderTopRadiusAnimated,
64
65
  borderTopRightRadius: borderTopRadiusAnimated,
65
66
  transform: [{ translateY }],
66
- height: WINDOW_HEIGHT,
67
+ height: screenHeight,
67
68
  },
68
69
  ]}
69
70
  >
@@ -73,7 +74,7 @@ export function AnimatedModal({
73
74
  {
74
75
  borderTopLeftRadius: borderTopRadiusAnimated,
75
76
  borderTopRightRadius: borderTopRadiusAnimated,
76
- height: WINDOW_HEIGHT,
77
+ height: screenHeight,
77
78
  },
78
79
  ]}
79
80
  >
@@ -18,7 +18,7 @@ import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-component
18
18
  import { useSafeAreaInsets } from "react-native-safe-area-context";
19
19
  import { GestureAnimatedScrollView } from "./GestureAnimatedScrollView";
20
20
  import { PlayerDetailsWrapperHeightContext } from "./context";
21
- import { getWindowHeight, getWindowWidth } from "./utils";
21
+ import { getScreenHeight, getWindowHeight, getWindowWidth } from "./utils";
22
22
 
23
23
  const orientationStyles = StyleSheet.create({
24
24
  landscape: { flexDirection: "row" },
@@ -61,6 +61,7 @@ export function VideoPlayerModal({
61
61
 
62
62
  const WINDOW_WIDTH = useMemo(() => getWindowWidth(), []); // remember initial width, ignore rotation changes
63
63
  const height = useMemo(() => getWindowHeight(), []); // remember initial height, ignore rotation changes
64
+ const screenHeight = useMemo(() => getScreenHeight(), []); // remember initial height, ignore rotation changes
64
65
  const MODAL_COLLAPSE_START = height * MODAL_COLLAPSE_RATIO;
65
66
 
66
67
  let width = WINDOW_WIDTH;
@@ -129,7 +130,12 @@ export function VideoPlayerModal({
129
130
  outputRange: [
130
131
  0,
131
132
  isTablet && isTabletLandscape
132
- ? -((-PROGRESS_BAR_HEIGHT + height - vidHeight * SCALE_FACTOR) / 2)
133
+ ? -(
134
+ (-PROGRESS_BAR_HEIGHT +
135
+ screenHeight -
136
+ vidHeight * SCALE_FACTOR) /
137
+ 2
138
+ )
133
139
  : -(
134
140
  PROGRESS_BAR_HEIGHT +
135
141
  insets.top / 2 +
@@ -186,7 +192,7 @@ export function VideoPlayerModal({
186
192
  borderTopLeftRadius: borderTopRadiusAnimated,
187
193
  borderTopRightRadius: borderTopRadiusAnimated,
188
194
  transform: [{ translateY: isFullScreenOrPIP ? 0 : translateY }],
189
- height: height,
195
+ height: screenHeight,
190
196
  },
191
197
  ]}
192
198
  >
@@ -198,13 +204,16 @@ export function VideoPlayerModal({
198
204
  {
199
205
  borderTopLeftRadius: borderTopRadiusAnimated,
200
206
  borderTopRightRadius: borderTopRadiusAnimated,
201
- height: height,
207
+ height: screenHeight,
202
208
  },
203
209
  ]}
204
210
  >
205
211
  <Animated.View
206
212
  pointerEvents={!collapsed ? "auto" : "none"}
207
- style={[styles.modalContent, directionStyles(isTabletLandscape)]}
213
+ style={[
214
+ pip ? styles.modalContentPiP : styles.modalContent,
215
+ directionStyles(isTabletLandscape),
216
+ ]}
208
217
  >
209
218
  <Animated.View
210
219
  style={[
@@ -1,5 +1,8 @@
1
1
  import { useCallback, useEffect, useMemo, useRef } from "react";
2
- import { useSafeAreaInsets } from "react-native-safe-area-context";
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 { getWindowHeight } from "../utils";
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 { bottom } = useSafeAreaInsets();
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) +
53
53
  PROGRESS_BAR_HEIGHT;
54
54
 
55
- const heightAboveMinimised = WINDOW_HEIGHT - collapsedHeight;
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
- }, [videoModalState.visible, videoModalState.mode, collapsedHeight]);
182
+ }, [
183
+ videoModalState.visible,
184
+ videoModalState.mode,
185
+ collapsedHeight,
186
+ heightAboveMinimised,
187
+ ]);
183
188
 
184
189
  return useMemo(
185
190
  () => ({
@@ -75,6 +75,10 @@ export const useStyles = ({ height }: { height: number }) => {
75
75
  flex: 1,
76
76
  alignItems: "center",
77
77
  },
78
+ modalContentPiP: {
79
+ flex: 1,
80
+ alignItems: "flex-start",
81
+ },
78
82
  expandedContentContainer: {
79
83
  justifyContent: "flex-start",
80
84
  backgroundColor: BG_COLOR_DEFAULT_TRANSPARENT,
@@ -1,25 +1,25 @@
1
- import { StatusBar, Dimensions } from "react-native";
1
+ import { Dimensions } from "react-native";
2
2
 
3
3
  import {
4
4
  isAndroidPlatform,
5
5
  isAndroidVersionAtLeast,
6
6
  } from "@applicaster/zapp-react-native-utils/reactUtils";
7
- import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
8
7
 
9
8
  const MIN_SUPPORTED_ANDROID_API = 34;
10
9
 
11
- const isOldAndroidDevice =
12
- isAndroidPlatform() &&
13
- !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API) &&
14
- !isAndroidTablet();
10
+ export const isOldAndroidDevice =
11
+ isAndroidPlatform() && !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API);
15
12
 
16
13
  export const getWindowHeight = (): number => {
17
14
  const windowDimensions = Dimensions.get("window");
18
15
 
19
- return (
20
- windowDimensions.height +
21
- (isOldAndroidDevice ? (StatusBar.currentHeight ?? 0) : 0)
22
- );
16
+ return windowDimensions.height;
17
+ };
18
+
19
+ export const getScreenHeight = (): number => {
20
+ const screenDimensions = Dimensions.get("screen");
21
+
22
+ return screenDimensions.height;
23
23
  };
24
24
 
25
25
  export const getWindowWidth = (): number => {
@@ -0,0 +1,23 @@
1
+ import { calculateLiveProgressBarTime } from "../utils";
2
+
3
+ describe("Utils", () => {
4
+ describe("calculateLiveProgressBarTime", () => {
5
+ it("Should return 0", () => {
6
+ expect(calculateLiveProgressBarTime(68, 1)).toBe(0);
7
+
8
+ expect(calculateLiveProgressBarTime(68, 0)).toBe(0);
9
+
10
+ expect(calculateLiveProgressBarTime(68, -1)).toBe(0);
11
+
12
+ expect(calculateLiveProgressBarTime(68, -5)).toBe(0);
13
+ });
14
+
15
+ it("Should return equal duration", () => {
16
+ expect(calculateLiveProgressBarTime(68, -100)).toBe(-68);
17
+
18
+ expect(calculateLiveProgressBarTime(68, -68)).toBe(-68);
19
+
20
+ expect(calculateLiveProgressBarTime(68, -105)).toBe(-68);
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,78 @@
1
+ import * as React from "react";
2
+
3
+ import { calculateLiveProgressBarTime, formatTimeDisplay } from "./utils";
4
+ import { ProgressState } from "./useProgressState";
5
+
6
+ // TODO: Must Add check RTL support
7
+ const getSliderValues = (seekableDuration: number, time: number) => {
8
+ const value = calculateLiveProgressBarTime(seekableDuration, time);
9
+
10
+ return {
11
+ minimumValue: -seekableDuration,
12
+ maximumValue: 0,
13
+ value: Math.min(0, value),
14
+ };
15
+ };
16
+
17
+ const prepareNewState = ({ seekableDuration, time }) => {
18
+ const sliderValues = getSliderValues(seekableDuration, time);
19
+
20
+ const getProgress = (
21
+ seekableDuration: number,
22
+ currentTime: number
23
+ ): number => {
24
+ return Math.round((currentTime / seekableDuration) * 100);
25
+ };
26
+
27
+ const getElapsedTime = (currentTime: number): string => {
28
+ return currentTime === 0
29
+ ? ""
30
+ : `-${formatTimeDisplay(Math.abs(currentTime))}`;
31
+ };
32
+
33
+ const getLiveOffsetPercent = (): number =>
34
+ (100 * (sliderValues.value - sliderValues.minimumValue)) /
35
+ (sliderValues.maximumValue - sliderValues.minimumValue);
36
+
37
+ return {
38
+ progress: getProgress(seekableDuration, sliderValues.value),
39
+ liveOffsetPercent: getLiveOffsetPercent(),
40
+ time: [getElapsedTime(sliderValues.value), null],
41
+ currentTime: sliderValues.value,
42
+ duration: Math.max(0, seekableDuration),
43
+ sliderValues,
44
+ };
45
+ };
46
+
47
+ // TODO: Add for `NOW` localization
48
+ export const useLiveProgressState = ({
49
+ playerState: { currentTime, seekableDuration },
50
+ }): [ProgressState, (seek: number) => void] => {
51
+ const stateRef = React.useRef<ProgressState>({
52
+ progress: 0,
53
+ liveOffsetPercent: 0,
54
+ time: ["--:--", "--:--"],
55
+ currentTime: 0,
56
+ duration: 0,
57
+ sliderValues: {
58
+ minimumValue: 0,
59
+ maximumValue: 0,
60
+ value: 0,
61
+ },
62
+ });
63
+
64
+ const updateState = React.useCallback(
65
+ (seekTime: number): void => {
66
+ if (seekTime == null || seekableDuration == null) {
67
+ return;
68
+ }
69
+
70
+ stateRef.current = prepareNewState({ seekableDuration, time: -seekTime });
71
+ },
72
+ [seekableDuration]
73
+ );
74
+
75
+ updateState(currentTime);
76
+
77
+ return [stateRef.current, updateState];
78
+ };
@@ -0,0 +1,29 @@
1
+ import { useLiveProgressState } from "./useLiveProgressState";
2
+ import { useVodProgressState } from "./useVodProgressState";
3
+
4
+ export type ProgressState = {
5
+ liveOffsetPercent?: number;
6
+ progress: number;
7
+ time: string[];
8
+ currentTime: number;
9
+ duration: number;
10
+ sliderValues: { minimumValue: number; maximumValue: number; value: number };
11
+ };
12
+
13
+ // TODO: Try refactor to remove code duplication
14
+ export const useProgressState = ({
15
+ playerState: { seekableDuration, duration, isLive },
16
+ remainingTimeDisplay = false,
17
+ currentTime,
18
+ }): [ProgressState, (seek) => void] => {
19
+ const liveData = useLiveProgressState({
20
+ playerState: { currentTime, seekableDuration },
21
+ });
22
+
23
+ const vodData = useVodProgressState({
24
+ playerState: { currentTime, duration },
25
+ remainingTimeDisplay,
26
+ });
27
+
28
+ return isLive ? liveData : vodData;
29
+ };
@@ -0,0 +1,115 @@
1
+ import * as React from "react";
2
+
3
+ import { formatTimeDisplay } from "./utils";
4
+ import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
5
+ import { ProgressState } from "./useProgressState";
6
+
7
+ // TODO: Refactor if needed, code was aligned to new structure only
8
+
9
+ const getSliderValues = (duration: number, time: number, isRTL: boolean) => {
10
+ const minimumValue = 0;
11
+
12
+ // Default max value should be greater than duration due to RTL thumb animation
13
+ const maximumValue = duration || 9999;
14
+ const initValue = isRTL ? maximumValue : minimumValue;
15
+ const currentValue = isRTL ? duration - time : time;
16
+ const progressValue = !duration ? initValue : currentValue;
17
+ const timeValue = !duration ? minimumValue : time;
18
+
19
+ return {
20
+ minimumValue,
21
+ maximumValue,
22
+ value: Math.max(0, progressValue),
23
+ timeValue: Math.max(0, timeValue),
24
+ };
25
+ };
26
+
27
+ const prepareNewState = ({ duration, time, remainingTimeDisplay, isRTL }) => {
28
+ const sliderValues = getSliderValues(duration, time, isRTL);
29
+
30
+ const getProgress = (duration, currentTime): number => {
31
+ return Math.round((currentTime / duration) * 100);
32
+ };
33
+
34
+ const getElapsedTime = (currentTime): string => {
35
+ return formatTimeDisplay(currentTime);
36
+ };
37
+
38
+ const getRemainingTime = (duration, currentTime): string => {
39
+ if (isNaN(duration)) {
40
+ return "--:--";
41
+ }
42
+
43
+ return formatTimeDisplay(duration - currentTime);
44
+ };
45
+
46
+ const remaining = getRemainingTime(duration, sliderValues.value);
47
+
48
+ const remainingTimeState = remainingTimeDisplay
49
+ ? `-${remaining}`
50
+ : formatTimeDisplay(duration);
51
+
52
+ return {
53
+ progress: getProgress(duration, sliderValues.value),
54
+ time: [getElapsedTime(sliderValues.timeValue), remainingTimeState],
55
+ currentTime: sliderValues.timeValue,
56
+ duration: Math.max(0, duration),
57
+ sliderValues,
58
+ };
59
+ };
60
+
61
+ export const useVodProgressState = ({
62
+ remainingTimeDisplay = false,
63
+ playerState: { currentTime, duration },
64
+ }): [ProgressState, (seek) => void] => {
65
+ const [state, setState] = React.useState<ProgressState>({
66
+ progress: 0,
67
+ time: ["--:--", "--:--"],
68
+ currentTime: 0,
69
+ duration: 0,
70
+ sliderValues: {
71
+ minimumValue: 0,
72
+ maximumValue: 0,
73
+ value: 0,
74
+ },
75
+ });
76
+
77
+ const isRTL = useIsRTL();
78
+
79
+ React.useEffect(() => {
80
+ if (currentTime == null || duration == null) {
81
+ return;
82
+ }
83
+
84
+ setState(
85
+ prepareNewState({
86
+ duration,
87
+ time: currentTime,
88
+ remainingTimeDisplay,
89
+ isRTL,
90
+ })
91
+ );
92
+ }, [currentTime, duration, isRTL, remainingTimeDisplay]);
93
+
94
+ const updateState = React.useCallback(
95
+ (seekTime?: number): void => {
96
+ if (seekTime == null || duration == null) {
97
+ return;
98
+ }
99
+
100
+ const time =
101
+ (seekTime || seekTime === 0) && Math.abs(seekTime - currentTime) > 1
102
+ ? seekTime
103
+ : currentTime;
104
+
105
+ if (duration && (time || time === 0)) {
106
+ setState(
107
+ prepareNewState({ duration, time, remainingTimeDisplay, isRTL })
108
+ );
109
+ }
110
+ },
111
+ [duration, currentTime, remainingTimeDisplay, isRTL]
112
+ );
113
+
114
+ return [state, updateState];
115
+ };
@@ -0,0 +1,33 @@
1
+ const prependZeroIfNeeded = (value) => {
2
+ const s = typeof value === "number" ? String(value) : String(value ?? "");
3
+
4
+ return `0${s}`.slice(-2);
5
+ };
6
+
7
+ export const calculateLiveProgressBarTime = (duration, time) => {
8
+ const minimumLiveOffsetStart = -5;
9
+
10
+ if (time < minimumLiveOffsetStart && time > -duration) {
11
+ // -67 < -5 && -67 > -68
12
+ return time;
13
+ } else if (time <= -duration) {
14
+ return -duration;
15
+ }
16
+
17
+ return 0;
18
+ };
19
+
20
+ export function formatTimeDisplay(durationInSeconds) {
21
+ const hours = Math.floor(durationInSeconds / 60 / 60);
22
+ const minutes = Math.floor((durationInSeconds - hours * 60 * 60) / 60);
23
+
24
+ const seconds = Math.floor(
25
+ durationInSeconds - hours * 60 * 60 - minutes * 60
26
+ );
27
+
28
+ const hr = prependZeroIfNeeded(hours);
29
+ const mn = prependZeroIfNeeded(minutes);
30
+ const sc = prependZeroIfNeeded(seconds);
31
+
32
+ return `${hours ? `${hr}:` : ""}${mn || "00"}:${sc}`;
33
+ }
@@ -1128,10 +1128,10 @@ export default class VideoPlayer extends React.Component<
1128
1128
  isTV() && this.getPlayNextData() && !docked;
1129
1129
 
1130
1130
  const needsToRender =
1131
- (!hideTransportControls &&
1132
- !needToShowPlayNextOverlay &&
1133
- this.props.mode !== "PIP") ||
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?.();