@applicaster/quick-brick-player 12.0.0-alpha.7754333813 → 12.0.0-alpha.7843515010
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 +9 -9
- package/src/CellPlayer/Assets/AssetsComponent.tsx +59 -49
- package/src/CellPlayer/ContextProvider.tsx +50 -1
- package/src/Player/AudioLayer/AudioPlayerWrapper.tsx +1 -0
- package/src/Player/AudioLayer/Layout/DefaultLayout.tsx +1 -0
- package/src/Player/AudioLayer/Layout/DockedLayout.tsx +13 -12
- package/src/Player/AudioLayer/MagicBG/index.tsx +46 -14
- package/src/Player/Utils/Utils.ts +6 -2
- package/src/Player/index.tsx +45 -117
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.7843515010",
|
|
4
4
|
"description": "Quick Brick Player",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@applicaster/quick-brick-mobile-transport-controls": "12.0.0-rc.
|
|
40
|
-
"@applicaster/quick-brick-tv-transport-controls": "12.0.0-rc.
|
|
41
|
-
"@applicaster/zapp-react-native-tvos-app": "12.0.0-alpha.
|
|
42
|
-
"@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.
|
|
43
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
39
|
+
"@applicaster/quick-brick-mobile-transport-controls": "12.0.0-rc.106",
|
|
40
|
+
"@applicaster/quick-brick-tv-transport-controls": "12.0.0-rc.109",
|
|
41
|
+
"@applicaster/zapp-react-native-tvos-app": "12.0.0-alpha.7843515010",
|
|
42
|
+
"@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.7843515010",
|
|
43
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.7843515010",
|
|
44
44
|
"keymirror": "^0.1.1",
|
|
45
45
|
"query-string": "7.1.3",
|
|
46
46
|
"react-native-web-linear-gradient": "1.1.2",
|
|
47
47
|
"shaka-player": "4.3.5",
|
|
48
48
|
"typeface-montserrat": "^0.0.54",
|
|
49
|
-
"video.js": "
|
|
50
|
-
"videojs-contrib-eme": "^
|
|
51
|
-
"videojs-contrib-quality-levels": "
|
|
49
|
+
"video.js": "8.21.0",
|
|
50
|
+
"videojs-contrib-eme": "^5.5.1",
|
|
51
|
+
"videojs-contrib-quality-levels": "^4.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@applicaster/quick-brick-xray": "*",
|
|
@@ -10,66 +10,76 @@ type Asset = string | undefined;
|
|
|
10
10
|
const isCurrentPlayer = (playerId) =>
|
|
11
11
|
LiveImageManager.instance.getCurrentlyPlaying()?.playerId === playerId;
|
|
12
12
|
|
|
13
|
+
const liveImageButtonsListenerKey = "live-image-buttons";
|
|
14
|
+
|
|
13
15
|
const usePlayPauseListeners = (playerId, player, asset, setImageUri) =>
|
|
14
16
|
useEffect(() => {
|
|
15
17
|
if (playerId && player) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
setImageUri(null);
|
|
19
|
+
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (player.playerState.isReadyToPlay) {
|
|
24
|
+
if (player.playerState.isPaused) {
|
|
25
|
+
setImageUri(asset.active);
|
|
26
|
+
} else {
|
|
27
|
+
setImageUri(asset.inactive);
|
|
22
28
|
}
|
|
29
|
+
}
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
onPlayerPause: () => {
|
|
31
|
-
setImageUri(asset.active);
|
|
32
|
-
},
|
|
33
|
-
onPlayerClose: () => {
|
|
34
|
-
setImageUri(null);
|
|
35
|
-
},
|
|
36
|
-
onLoad() {
|
|
37
|
-
setImageUri(asset.inactive);
|
|
38
|
-
},
|
|
31
|
+
return player.addListener({
|
|
32
|
+
id: liveImageButtonsListenerKey,
|
|
33
|
+
listener: {
|
|
34
|
+
onPlayerResume: () => {
|
|
35
|
+
setImageUri(asset.inactive);
|
|
39
36
|
},
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
onPlayerPause: () => {
|
|
38
|
+
setImageUri(asset.active);
|
|
39
|
+
},
|
|
40
|
+
onPlayerClose: () => {
|
|
41
|
+
setImageUri(null);
|
|
42
|
+
},
|
|
43
|
+
onLoad() {
|
|
44
|
+
setImageUri(asset.inactive);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
42
48
|
}, [player, playerId, asset]);
|
|
43
49
|
|
|
44
50
|
const useMuteUnmuteListeners = (playerId, player, asset, setImageUri) =>
|
|
45
51
|
useEffect(() => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
listener: {
|
|
51
|
-
onPlayerMute: () => {
|
|
52
|
-
if (isCurrentPlayer(playerId)) {
|
|
53
|
-
setImageUri(asset.active);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
onPlayerUnmute: () => {
|
|
57
|
-
if (isCurrentPlayer(playerId)) {
|
|
58
|
-
setImageUri(asset.inactive);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
onLoad() {
|
|
62
|
-
setImageUri(player?.getIsMuted() ? asset.active : asset.inactive);
|
|
63
|
-
},
|
|
64
|
-
onPlayerClose: () => {
|
|
65
|
-
setImageUri(null);
|
|
66
|
-
},
|
|
67
|
-
onVideoEnd: () => {
|
|
68
|
-
setImageUri(null);
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
});
|
|
52
|
+
if (!player || !playerId) {
|
|
53
|
+
setImageUri(null);
|
|
54
|
+
|
|
55
|
+
return;
|
|
72
56
|
}
|
|
57
|
+
|
|
58
|
+
// active action = muted, inactive = unmuted
|
|
59
|
+
return player.addListener({
|
|
60
|
+
id: liveImageButtonsListenerKey,
|
|
61
|
+
listener: {
|
|
62
|
+
onPlayerMute: () => {
|
|
63
|
+
if (isCurrentPlayer(playerId)) {
|
|
64
|
+
setImageUri(asset.active);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
onPlayerUnmute: () => {
|
|
68
|
+
if (isCurrentPlayer(playerId)) {
|
|
69
|
+
setImageUri(asset.inactive);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
onLoad() {
|
|
73
|
+
setImageUri(player?.getIsMuted() ? asset.active : asset.inactive);
|
|
74
|
+
},
|
|
75
|
+
onPlayerClose: () => {
|
|
76
|
+
setImageUri(null);
|
|
77
|
+
},
|
|
78
|
+
onVideoEnd: () => {
|
|
79
|
+
setImageUri(null);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
73
83
|
}, [player, playerId, asset]);
|
|
74
84
|
|
|
75
85
|
const useListeners = MUTED_USAGE
|
|
@@ -21,7 +21,7 @@ const playActionCallback = (player) => {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const invokeAction = () => {
|
|
24
|
+
const invokeAction = (_item: ZappEntry, _object) => {
|
|
25
25
|
const actionCallback = MUTED_USAGE ? muteActionCallback : playActionCallback;
|
|
26
26
|
// We only allow one player to be present at a time
|
|
27
27
|
const player = LiveImageManager.instance.getCurrentlyPlaying()?.player;
|
|
@@ -29,6 +29,54 @@ const invokeAction = () => {
|
|
|
29
29
|
actionCallback(player);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
// Not exported because currently the is no way
|
|
33
|
+
// to subscribe to the action availability change.
|
|
34
|
+
// We currently return a null state to disable the action.
|
|
35
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
36
|
+
const isActionAvailable = (item: ZappEntry) => {
|
|
37
|
+
return (
|
|
38
|
+
LiveImageManager.instance.getCurrentlyPlaying()?.getPlayer().entry.id ===
|
|
39
|
+
item.id
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const addListener = (
|
|
44
|
+
entryId: string,
|
|
45
|
+
listener: CellActionStateListenerFunction
|
|
46
|
+
) => {
|
|
47
|
+
const callback = (event: Record<string, any>) => {
|
|
48
|
+
if (event.entry?.id !== entryId) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const player = LiveImageManager.instance.getCurrentlyPlaying()?.getPlayer();
|
|
53
|
+
|
|
54
|
+
if (!player || player.entry?.id !== entryId) {
|
|
55
|
+
listener(null);
|
|
56
|
+
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const actionState = MUTED_USAGE ? player.getIsMuted() : player.isPaused();
|
|
61
|
+
|
|
62
|
+
listener({
|
|
63
|
+
state: actionState ? 1 : 0,
|
|
64
|
+
label: "",
|
|
65
|
+
asset: AssetComponent,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return LiveImageManager.instance.addListener({
|
|
70
|
+
id: `cell-player-${entryId}`,
|
|
71
|
+
listener: {
|
|
72
|
+
onEnd: callback,
|
|
73
|
+
onStart: callback,
|
|
74
|
+
onError: callback,
|
|
75
|
+
onDestroy: callback,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
32
80
|
const emptyState = [];
|
|
33
81
|
|
|
34
82
|
const initialEntryState = () => ({
|
|
@@ -46,6 +94,7 @@ export function ContextProvider(Component: ReactComponent<any>) {
|
|
|
46
94
|
state: emptyState,
|
|
47
95
|
invokeAction,
|
|
48
96
|
initialEntryState,
|
|
97
|
+
addListener,
|
|
49
98
|
}),
|
|
50
99
|
[invokeAction, initialEntryState]
|
|
51
100
|
);
|
|
@@ -388,6 +388,7 @@ export const AudioPlayerWrapper: React.FC<Props> = (props: Props) => {
|
|
|
388
388
|
<AnimationComponent
|
|
389
389
|
animationType={ComponentAnimationType.moveUpComponent}
|
|
390
390
|
additionalData={{ saveArea: true }}
|
|
391
|
+
style={Styles.playerContainer}
|
|
391
392
|
>
|
|
392
393
|
<AnimatedScrollModal>
|
|
393
394
|
<View style={Styles.playerContainer} onLayout={onLayout}>
|
|
@@ -419,6 +419,7 @@ export default function DefaultLayout(props: LayoutProps) {
|
|
|
419
419
|
startTimestamp={startTimestamp}
|
|
420
420
|
endTimestamp={endTimestamp}
|
|
421
421
|
isDateBasedLiveContent={isDateBasedLiveContent}
|
|
422
|
+
onSkipLive={onSkipLive}
|
|
422
423
|
/>
|
|
423
424
|
|
|
424
425
|
{showCounter && timeLeft >= 0 && (
|
|
@@ -117,7 +117,6 @@ const playerDimensionsStyle = (
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
const animatedContainerStyle = (docked: boolean): ViewStyle => ({
|
|
120
|
-
top: docked ? 2 : null,
|
|
121
120
|
position: "absolute",
|
|
122
121
|
width: "100%",
|
|
123
122
|
zIndex: docked ? 1 : -1,
|
|
@@ -245,17 +244,19 @@ export default function DockedLayout(props: LayoutProps) {
|
|
|
245
244
|
animatedContainerStyle(isActiveGesture || layoutState.docked),
|
|
246
245
|
]}
|
|
247
246
|
>
|
|
248
|
-
{!playerState.isLive &&
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
247
|
+
{!playerState.isLive &&
|
|
248
|
+
(layoutState.docked || startComponentsAnimation) && (
|
|
249
|
+
<ProgressBar
|
|
250
|
+
content={entry}
|
|
251
|
+
value={value}
|
|
252
|
+
visible={visible}
|
|
253
|
+
layoutState={layoutState}
|
|
254
|
+
onPlayerSeek={onPlayerSeek}
|
|
255
|
+
playerState={playerState}
|
|
256
|
+
startComponentsAnimation={startComponentsAnimation}
|
|
257
|
+
docked
|
|
258
|
+
/>
|
|
259
|
+
)}
|
|
259
260
|
|
|
260
261
|
<View style={styles.content}>
|
|
261
262
|
<View
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// Disabling for now as lint can't recognise typescript definition here
|
|
2
1
|
/* eslint-disable react/prop-types */
|
|
3
2
|
import * as React from "react";
|
|
4
|
-
import { StyleSheet, View } from "react-native";
|
|
3
|
+
import { Animated, StyleSheet, View } from "react-native";
|
|
5
4
|
import LinearGradient from "../LinearGradient";
|
|
6
5
|
import { getDominantColor, getPalettes } from "../../../utils/utils";
|
|
7
6
|
import { useEffect } from "react";
|
|
@@ -11,7 +10,7 @@ type MagicBGProps = {
|
|
|
11
10
|
image: string;
|
|
12
11
|
fallbackUrl?: string;
|
|
13
12
|
defaultColor: string;
|
|
14
|
-
colors: string[];
|
|
13
|
+
colors: string[];
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
const defaultColors = {
|
|
@@ -66,31 +65,46 @@ export const MagicBG: React.FC<MagicBGProps> = ({
|
|
|
66
65
|
defaultColors.defaultGradientEnd,
|
|
67
66
|
]);
|
|
68
67
|
|
|
68
|
+
const [backgroundColorAnim] = React.useState(new Animated.Value(0)); // from 0 to 1
|
|
69
|
+
const [gradientOpacityAnim] = React.useState(new Animated.Value(0)); // from 0 to 1
|
|
70
|
+
|
|
69
71
|
useEffect(() => {
|
|
72
|
+
const animateColors = () => {
|
|
73
|
+
Animated.timing(backgroundColorAnim, {
|
|
74
|
+
toValue: 1,
|
|
75
|
+
duration: 500,
|
|
76
|
+
useNativeDriver: false,
|
|
77
|
+
}).start();
|
|
78
|
+
|
|
79
|
+
Animated.timing(gradientOpacityAnim, {
|
|
80
|
+
toValue: 1,
|
|
81
|
+
duration: 500,
|
|
82
|
+
useNativeDriver: false,
|
|
83
|
+
}).start();
|
|
84
|
+
};
|
|
85
|
+
|
|
70
86
|
const fetchColors = async () => {
|
|
71
|
-
// Check if colors are provided and not empty
|
|
72
87
|
if (colors && colors.length > 0) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
setGradientColors(colors.slice(0, 2));
|
|
89
|
+
setDominantColor(colors[0]);
|
|
90
|
+
animateColors();
|
|
76
91
|
} else if (image) {
|
|
77
|
-
// If no colors, try fetching from image
|
|
78
92
|
try {
|
|
79
93
|
const { gradientColors, dominantColor } =
|
|
80
94
|
await fetchPaletteAndDominantColor(image);
|
|
81
95
|
|
|
82
96
|
setGradientColors(gradientColors);
|
|
83
97
|
setDominantColor(dominantColor);
|
|
98
|
+
animateColors();
|
|
84
99
|
} catch (error) {
|
|
85
|
-
// If image fetch fails, try fallback URL
|
|
86
100
|
try {
|
|
87
101
|
const { gradientColors, dominantColor } =
|
|
88
102
|
await fetchPaletteAndDominantColor(fallbackUrl);
|
|
89
103
|
|
|
90
104
|
setGradientColors(gradientColors);
|
|
91
105
|
setDominantColor(dominantColor);
|
|
106
|
+
animateColors();
|
|
92
107
|
} catch {
|
|
93
|
-
// If everything fails, use default color
|
|
94
108
|
setGradientColors([
|
|
95
109
|
defaultColors.defaultGradientStart,
|
|
96
110
|
defaultColors.defaultGradientEnd,
|
|
@@ -100,7 +114,6 @@ export const MagicBG: React.FC<MagicBGProps> = ({
|
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
} else {
|
|
103
|
-
// If no image or colors, use default color
|
|
104
117
|
setGradientColors([
|
|
105
118
|
defaultColors.defaultGradientStart,
|
|
106
119
|
defaultColors.defaultGradientEnd,
|
|
@@ -113,11 +126,30 @@ export const MagicBG: React.FC<MagicBGProps> = ({
|
|
|
113
126
|
fetchColors();
|
|
114
127
|
}, []);
|
|
115
128
|
|
|
129
|
+
const interpolatedBackgroundColor = backgroundColorAnim.interpolate({
|
|
130
|
+
inputRange: [0, 1],
|
|
131
|
+
outputRange: ["black", dominantColor],
|
|
132
|
+
});
|
|
133
|
+
|
|
116
134
|
return (
|
|
117
|
-
<View
|
|
135
|
+
<Animated.View
|
|
136
|
+
style={[
|
|
137
|
+
styles.container,
|
|
138
|
+
{ backgroundColor: interpolatedBackgroundColor },
|
|
139
|
+
]}
|
|
140
|
+
>
|
|
118
141
|
<View style={styles.fullScreenOverlay} />
|
|
119
|
-
|
|
142
|
+
|
|
143
|
+
<Animated.View
|
|
144
|
+
style={[styles.gradientOverlay, { opacity: gradientOpacityAnim }]}
|
|
145
|
+
>
|
|
146
|
+
<LinearGradient
|
|
147
|
+
colors={gradientColors}
|
|
148
|
+
style={StyleSheet.absoluteFill}
|
|
149
|
+
/>
|
|
150
|
+
</Animated.View>
|
|
151
|
+
|
|
120
152
|
{children}
|
|
121
|
-
</View>
|
|
153
|
+
</Animated.View>
|
|
122
154
|
);
|
|
123
155
|
};
|
|
@@ -22,6 +22,10 @@ export const addQueryParam = (
|
|
|
22
22
|
return `${urlWithoutQuery}?${updatedQueryString}`;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export const isValidDate = (dateString: string): boolean => {
|
|
26
|
-
return
|
|
25
|
+
export const isValidDate = (dateString: string | undefined): boolean => {
|
|
26
|
+
return (
|
|
27
|
+
typeof dateString === "string" &&
|
|
28
|
+
dateString.trim() !== "" &&
|
|
29
|
+
dayjs.utc(dateString).isValid()
|
|
30
|
+
);
|
|
27
31
|
};
|
package/src/Player/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import * as R from "ramda";
|
|
6
6
|
|
|
7
|
-
import { findNodeHandle,
|
|
7
|
+
import { findNodeHandle, StyleSheet, View } from "react-native";
|
|
8
8
|
import TransportControlsMobile from "@applicaster/quick-brick-mobile-transport-controls";
|
|
9
9
|
import TransportControlsTV from "@applicaster/quick-brick-tv-transport-controls";
|
|
10
10
|
|
|
@@ -21,14 +21,8 @@ import { PlayerWrapper } from "@applicaster/zapp-react-native-ui-components/Comp
|
|
|
21
21
|
|
|
22
22
|
import { PlayNextOverlay } from "./PlayNextOverlay";
|
|
23
23
|
import { PlayerImageBackground } from "@applicaster/zapp-react-native-ui-components/Components/PlayerImageBackground";
|
|
24
|
-
import { AnalyticsTracker } from "@applicaster/zapp-react-native-utils/analyticsUtils/analyticsTracker";
|
|
25
24
|
|
|
26
|
-
import {
|
|
27
|
-
AD_EVENT,
|
|
28
|
-
GENERAL_EVENT,
|
|
29
|
-
PLAYBACK_EVENT,
|
|
30
|
-
QOS_EVENT,
|
|
31
|
-
} from "@applicaster/zapp-react-native-utils/analyticsUtils/events";
|
|
25
|
+
import { GENERAL_EVENT } from "@applicaster/zapp-react-native-utils/analyticsUtils/events";
|
|
32
26
|
import { Categories, createLogger, Subsystem } from "../logger";
|
|
33
27
|
import { parseLanguageTracks } from "@applicaster/zapp-react-native-utils/playerUtils/configurationUtils";
|
|
34
28
|
import { DEFAULT_COLORS, SEEK_TIME } from "../utils/const";
|
|
@@ -42,15 +36,10 @@ import {
|
|
|
42
36
|
AnimationComponent,
|
|
43
37
|
ComponentAnimationType,
|
|
44
38
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
39
|
+
import { PlayerAnalyticsManager } from "@applicaster/zapp-react-native-utils/analyticsUtils/PlayerAnalyticsManager";
|
|
40
|
+
import { PlayerAnalyticsTrackerI } from "@applicaster/zapp-react-native-utils/analyticsUtils/playerAnalyticsTracker";
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
QuickBrickPlayerPlugin: isApplePlatform()
|
|
48
|
-
? NativeModules.PlayerModule
|
|
49
|
-
: NativeModules.QuickBrickDefaultPlayerModule,
|
|
50
|
-
KalturaPlayerPlugin: isApplePlatform()
|
|
51
|
-
? NativeModules.KalturaPlayerModule
|
|
52
|
-
: NativeModules.QBKalturaPlayerModule,
|
|
53
|
-
};
|
|
42
|
+
import { RNPlayerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/nativePlayerManager";
|
|
54
43
|
|
|
55
44
|
const styles = StyleSheet.create({
|
|
56
45
|
container: { flex: 1 },
|
|
@@ -75,7 +64,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
75
64
|
> {
|
|
76
65
|
public static propTypes = {};
|
|
77
66
|
_root: any;
|
|
78
|
-
analyticsTracker: AnalyticsTracker;
|
|
79
67
|
playerPluginId: string;
|
|
80
68
|
takeParentStyle: Record<any, any>;
|
|
81
69
|
playbackStarted = false;
|
|
@@ -106,6 +94,17 @@ export default class VideoPlayer extends React.Component<
|
|
|
106
94
|
duration: 0,
|
|
107
95
|
};
|
|
108
96
|
|
|
97
|
+
private _tracker: PlayerAnalyticsTrackerI;
|
|
98
|
+
get analyticsTracker() {
|
|
99
|
+
if (!this._tracker) {
|
|
100
|
+
this._tracker = PlayerAnalyticsManager.getInstance().getTracker(
|
|
101
|
+
this.props.playerId
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return this._tracker;
|
|
106
|
+
}
|
|
107
|
+
|
|
109
108
|
constructor(props) {
|
|
110
109
|
super(props);
|
|
111
110
|
this.onVideoLoadCalled = false; // android
|
|
@@ -114,16 +113,13 @@ export default class VideoPlayer extends React.Component<
|
|
|
114
113
|
? { width: "100%", flex: "1 1 auto", objectFit: "contain" }
|
|
115
114
|
: { flexBasis: "auto", flexGrow: 1, flexShrink: 1 };
|
|
116
115
|
|
|
117
|
-
const entry = this.props?.entry;
|
|
118
|
-
this.analyticsTracker = new AnalyticsTracker(entry);
|
|
119
116
|
this.playerPluginId = this.props?.playerPluginIdentifier;
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
componentWillUnmount() {
|
|
123
|
-
this.stopBackgroundPlayback();
|
|
124
|
-
|
|
125
120
|
this.playbackStarted = false;
|
|
126
|
-
|
|
121
|
+
|
|
122
|
+
this.analyticsTracker.handleAnalyticEvent(GENERAL_EVENT.session_end);
|
|
127
123
|
this.onPlayerClosed();
|
|
128
124
|
|
|
129
125
|
if (isAndroidPlatform()) {
|
|
@@ -166,6 +162,11 @@ export default class VideoPlayer extends React.Component<
|
|
|
166
162
|
}
|
|
167
163
|
}
|
|
168
164
|
|
|
165
|
+
// For close button
|
|
166
|
+
public closeNativePlayer = () => {
|
|
167
|
+
this.stopBackgroundPlayback();
|
|
168
|
+
};
|
|
169
|
+
|
|
169
170
|
getPlayNextData = () => this.props.playNextData as PlayNextData;
|
|
170
171
|
|
|
171
172
|
/**
|
|
@@ -179,27 +180,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
179
180
|
return this.props.pluginConfiguration;
|
|
180
181
|
};
|
|
181
182
|
|
|
182
|
-
/**
|
|
183
|
-
* Handles analytic events, generates a new analytics tracker and transmits events
|
|
184
|
-
* Passes entry data, and playerState to the tracker for additional context
|
|
185
|
-
* The end result is an event formatted and passed to AnalyticsBridge.postEvent
|
|
186
|
-
* When we get the synthetic event we need to pull the data in the nativeEvent object
|
|
187
|
-
* nativeEvent contains the return value from native
|
|
188
|
-
*/
|
|
189
|
-
handleAnalyticEvent = (event, data = {}) => {
|
|
190
|
-
const entry = this.props?.entry;
|
|
191
|
-
const playerState = this.getState();
|
|
192
|
-
|
|
193
|
-
if (this.analyticsTracker?.handleAnalyticEvent) {
|
|
194
|
-
this.analyticsTracker?.handleAnalyticEvent?.(
|
|
195
|
-
event,
|
|
196
|
-
{ ...data, player_type: this.props.playerPluginIdentifier },
|
|
197
|
-
entry,
|
|
198
|
-
playerState
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
183
|
/**
|
|
204
184
|
* This method is for the events that have no implementation in react but are being invoked by native
|
|
205
185
|
* When we get the synthetic event we need to pull the data in the nativeEvent object
|
|
@@ -340,11 +320,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
340
320
|
}
|
|
341
321
|
};
|
|
342
322
|
|
|
343
|
-
|
|
344
|
-
* Sets either subtitle language, or audio language if we have a selected a new locale.
|
|
345
|
-
* If no locale is set it defaults to system language for audio, and leaves subtitles unaltered.
|
|
346
|
-
*/
|
|
347
|
-
setLanguage = (selected = null) => {
|
|
323
|
+
selectTrack = (selected) => {
|
|
348
324
|
const { trackType, id, language } = selected || {};
|
|
349
325
|
|
|
350
326
|
const isOff = language === "Off";
|
|
@@ -403,28 +379,16 @@ export default class VideoPlayer extends React.Component<
|
|
|
403
379
|
};
|
|
404
380
|
|
|
405
381
|
onPlayerPresented = () => {
|
|
406
|
-
this.handleAnalyticEvent(GENERAL_EVENT.player_presented);
|
|
382
|
+
this.analyticsTracker?.handleAnalyticEvent(GENERAL_EVENT.player_presented);
|
|
407
383
|
};
|
|
408
384
|
|
|
409
385
|
onPlayerClosed = () => {
|
|
410
|
-
this.handleAnalyticEvent(GENERAL_EVENT.player_closed);
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
onPlayerSessionEnd = () => {
|
|
414
|
-
// TODO: Implement method on native android, ios exists
|
|
415
|
-
this.handleAnalyticEvent(GENERAL_EVENT.session_end);
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
onPlayerSessionStart = () => {
|
|
419
|
-
// TODO: Implement method on native android, ios exists
|
|
420
|
-
|
|
421
|
-
this.handleAnalyticEvent(GENERAL_EVENT.session_start);
|
|
386
|
+
this.analyticsTracker?.handleAnalyticEvent(GENERAL_EVENT.player_closed);
|
|
422
387
|
};
|
|
423
388
|
|
|
424
389
|
onVideoEnd = () => {
|
|
425
390
|
this.setState({ displayOverlay: !this.state.displayOverlay }, () => {
|
|
426
391
|
if (this.state?.displayOverlay) {
|
|
427
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.complete);
|
|
428
392
|
this.props?.listener?.onVideoEnd({});
|
|
429
393
|
}
|
|
430
394
|
});
|
|
@@ -434,15 +398,12 @@ export default class VideoPlayer extends React.Component<
|
|
|
434
398
|
onVideoError = ({ nativeEvent }) => {
|
|
435
399
|
const { message } = nativeEvent;
|
|
436
400
|
|
|
437
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.error, nativeEvent);
|
|
438
|
-
|
|
439
401
|
return this.props?.listener?.onError(new Error(message));
|
|
440
402
|
};
|
|
441
403
|
|
|
442
404
|
onPlayerPause = ({ nativeEvent = null }) => {
|
|
443
405
|
this.setState({ paused: true });
|
|
444
406
|
this.props?.listener?.onPlayerPause(nativeEvent);
|
|
445
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.pause, nativeEvent);
|
|
446
407
|
};
|
|
447
408
|
|
|
448
409
|
onPlayerResume = ({ nativeEvent = null }) => {
|
|
@@ -453,98 +414,61 @@ export default class VideoPlayer extends React.Component<
|
|
|
453
414
|
|
|
454
415
|
if (isNotAnAd && !resume) {
|
|
455
416
|
this.setState({ resume: true });
|
|
456
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.play, nativeEvent);
|
|
457
417
|
}
|
|
458
418
|
};
|
|
459
419
|
|
|
460
420
|
onPlayerSeekComplete = ({ nativeEvent }) => {
|
|
461
421
|
this.props?.listener?.onPlayerSeekComplete(nativeEvent);
|
|
462
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.seek_complete, nativeEvent);
|
|
463
422
|
};
|
|
464
423
|
|
|
465
424
|
onPlayerSeekStart = ({ nativeEvent }) => {
|
|
466
425
|
this.props?.listener?.onPlayerSeekStart(nativeEvent);
|
|
467
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.seek_start, nativeEvent);
|
|
468
426
|
};
|
|
469
427
|
|
|
470
428
|
onBufferStart = ({ nativeEvent }) => {
|
|
471
429
|
this.props?.listener?.onBufferStart(nativeEvent);
|
|
472
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.buffer_start, nativeEvent);
|
|
473
430
|
};
|
|
474
431
|
|
|
475
432
|
onBufferComplete = ({ nativeEvent }) => {
|
|
476
433
|
this.props?.listener?.onBufferComplete(nativeEvent);
|
|
477
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.buffer_complete, nativeEvent);
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
onPlayerNext = ({ nativeEvent }) => {
|
|
481
|
-
// TODO: Implement method on native
|
|
482
|
-
|
|
483
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.next, nativeEvent);
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
onPlayerPrevious = ({ nativeEvent }) => {
|
|
487
|
-
// TODO: Implement method on native
|
|
488
|
-
|
|
489
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.previous, nativeEvent);
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
onPlayerStop = ({ nativeEvent }) => {
|
|
493
|
-
// TODO: Implement method on native
|
|
494
|
-
|
|
495
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.stop, nativeEvent);
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
onVideoBandwidthUpdate = ({ nativeEvent }) => {
|
|
499
|
-
// TODO: Implement method on native
|
|
500
|
-
|
|
501
|
-
this.handleAnalyticEvent(QOS_EVENT.bitrate_changed, nativeEvent);
|
|
502
434
|
};
|
|
503
435
|
|
|
504
436
|
onAdBegin = ({ nativeEvent }) => {
|
|
505
437
|
this.setState({ isAd: true });
|
|
506
|
-
this.handleAnalyticEvent(AD_EVENT.ad_start, nativeEvent);
|
|
507
438
|
this.props.listener?.onAdBegin?.(nativeEvent);
|
|
508
439
|
};
|
|
509
440
|
|
|
510
441
|
onAdBreakBegin = ({ nativeEvent }) => {
|
|
511
442
|
this.setState({ isAd: true });
|
|
512
|
-
this.handleAnalyticEvent(AD_EVENT.ad_break_start, nativeEvent);
|
|
513
443
|
this.props.listener?.onAdBreakBegin?.(nativeEvent);
|
|
514
444
|
};
|
|
515
445
|
|
|
516
446
|
onAdBreakEnd = ({ nativeEvent }) => {
|
|
517
447
|
this.setState({ isAd: false });
|
|
518
|
-
this.handleAnalyticEvent(AD_EVENT.ad_break_completed, nativeEvent);
|
|
519
448
|
this.props.listener?.onAdBreakEnd?.(nativeEvent);
|
|
520
449
|
};
|
|
521
450
|
|
|
522
451
|
onAdEnd = ({ nativeEvent }) => {
|
|
523
452
|
this.setState({ isAd: false });
|
|
524
|
-
this.handleAnalyticEvent(AD_EVENT.ad_complete, nativeEvent);
|
|
525
453
|
this.props.listener?.onAdEnd?.(nativeEvent);
|
|
526
454
|
};
|
|
527
455
|
|
|
528
456
|
onAdError = ({ nativeEvent }) => {
|
|
529
457
|
this.setState({ isAd: false });
|
|
530
|
-
this.handleAnalyticEvent(AD_EVENT.ad_error, nativeEvent);
|
|
531
458
|
this.props.listener?.onAdError?.(nativeEvent);
|
|
532
459
|
};
|
|
533
460
|
|
|
534
461
|
onAdRequest = ({ nativeEvent }) => {
|
|
535
|
-
this.handleAnalyticEvent(AD_EVENT.ad_request, nativeEvent);
|
|
536
462
|
this.props.listener?.onAdRequest?.(nativeEvent);
|
|
537
463
|
};
|
|
538
464
|
|
|
539
465
|
onAdClicked = ({ nativeEvent }) => {
|
|
540
|
-
this.handleAnalyticEvent(AD_EVENT.ad_clicked, nativeEvent);
|
|
541
466
|
// Broadcast click event
|
|
542
467
|
this.props.playerEvent("ad-clicked", nativeEvent);
|
|
543
468
|
this.props.listener?.onAdClicked?.(nativeEvent);
|
|
544
469
|
};
|
|
545
470
|
|
|
546
471
|
onAdTapped = ({ nativeEvent }) => {
|
|
547
|
-
this.handleAnalyticEvent(AD_EVENT.ad_tapped, nativeEvent);
|
|
548
472
|
// Broadcast click event
|
|
549
473
|
this.props.playerEvent("ad-tapped", nativeEvent);
|
|
550
474
|
this.props.listener?.onAdTapped?.(nativeEvent);
|
|
@@ -657,10 +581,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
657
581
|
}
|
|
658
582
|
|
|
659
583
|
if (!this.state.isAd && !this.onVideoLoadCalled) {
|
|
660
|
-
this.handleAnalyticEvent(PLAYBACK_EVENT.load_video, {
|
|
661
|
-
player_type: this.props.playerPluginIdentifier,
|
|
662
|
-
});
|
|
663
|
-
|
|
664
584
|
// TODO: Hack, needs to remove
|
|
665
585
|
this.onVideoLoadCalled = true;
|
|
666
586
|
}
|
|
@@ -862,7 +782,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
862
782
|
!!this.props.controller?.supportsNativeControls?.();
|
|
863
783
|
|
|
864
784
|
const controls = isAppleTV()
|
|
865
|
-
? supportsNativeControls && !isInlineTV
|
|
785
|
+
? (supportsNativeControls && !isInlineTV) || !!this.getPlayNextData()
|
|
866
786
|
: supportsNativeControls && !this.getPlayNextData();
|
|
867
787
|
|
|
868
788
|
const shouldUseNativeControls =
|
|
@@ -928,8 +848,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
928
848
|
onPlayerResume: this.onPlayerResume, // play
|
|
929
849
|
onPlayerSeekComplete: this.onPlayerSeekComplete, // seek_complete
|
|
930
850
|
onPlayerSeekStart: this.onPlayerSeekStart, // seek_start
|
|
931
|
-
onPlayerSessionEnd: this.onPlayerSessionEnd, // session_end
|
|
932
|
-
onPlayerSessionStart: this.onPlayerSessionStart, // session_start
|
|
933
851
|
};
|
|
934
852
|
|
|
935
853
|
const lifecycleEvents = {
|
|
@@ -962,7 +880,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
962
880
|
onTimedMetadata: this.unHandledEvent("onTimedMetadata"),
|
|
963
881
|
onTracksChanged: this.onTracksChanged,
|
|
964
882
|
eventSubtitlesChange: this.unHandledEvent("eventSubtitlesChange"),
|
|
965
|
-
onVideoBandwidthUpdate: this.onVideoBandwidthUpdate,
|
|
966
883
|
};
|
|
967
884
|
|
|
968
885
|
const playerSystemEvents = {
|
|
@@ -982,9 +899,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
982
899
|
const unsupportedEvents = {
|
|
983
900
|
onBufferComplete: this.onBufferComplete, // buffer_complete
|
|
984
901
|
onBufferStart: this.onBufferStart, // buffer_start
|
|
985
|
-
onPlayerNext: this.onPlayerNext, // next
|
|
986
|
-
onPlayerPrevious: this.onPlayerPrevious, // previous
|
|
987
|
-
onPlayerStop: this.onPlayerStop, // stop
|
|
988
902
|
};
|
|
989
903
|
|
|
990
904
|
const nativeEvents = {
|
|
@@ -998,7 +912,13 @@ export default class VideoPlayer extends React.Component<
|
|
|
998
912
|
...androidLifecyclePiPEvents,
|
|
999
913
|
};
|
|
1000
914
|
|
|
1001
|
-
const needToShowPlayNextOverlay =
|
|
915
|
+
const needToShowPlayNextOverlay =
|
|
916
|
+
isTV() && this.getPlayNextData() && !docked;
|
|
917
|
+
|
|
918
|
+
const needToShowDefaultControls = !(
|
|
919
|
+
(controls && !castAction?.state?.connected) ||
|
|
920
|
+
this.getPlayNextData()
|
|
921
|
+
);
|
|
1002
922
|
|
|
1003
923
|
const playerContainerStyles = isApplePlatform()
|
|
1004
924
|
? styles.playerContainerBlack
|
|
@@ -1040,7 +960,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
1040
960
|
extraInfoText={castAction?.state?.friendlyStatus}
|
|
1041
961
|
controlsAlwaysVisible={castAction?.state?.connected}
|
|
1042
962
|
playNextData={this.getPlayNextData()}
|
|
1043
|
-
|
|
963
|
+
needToShowDefaultControls={needToShowDefaultControls}
|
|
1044
964
|
/>
|
|
1045
965
|
) : null;
|
|
1046
966
|
};
|
|
@@ -1106,7 +1026,11 @@ export default class VideoPlayer extends React.Component<
|
|
|
1106
1026
|
style={getStyle(playerDimensions)}
|
|
1107
1027
|
>
|
|
1108
1028
|
<AudioPlayer
|
|
1109
|
-
style={
|
|
1029
|
+
style={
|
|
1030
|
+
isTV()
|
|
1031
|
+
? getStyle(playerDimensions)
|
|
1032
|
+
: styles.playerSize
|
|
1033
|
+
}
|
|
1110
1034
|
audio_item={entry}
|
|
1111
1035
|
plugin_configuration={this.getPluginConfiguration()}
|
|
1112
1036
|
/>
|
|
@@ -1133,7 +1057,11 @@ export default class VideoPlayer extends React.Component<
|
|
|
1133
1057
|
{...nativeEvents}
|
|
1134
1058
|
{...nativeProps}
|
|
1135
1059
|
listener={this.props.listener}
|
|
1136
|
-
style={
|
|
1060
|
+
style={
|
|
1061
|
+
isTV()
|
|
1062
|
+
? getStyle(playerDimensions)
|
|
1063
|
+
: styles.playerSize
|
|
1064
|
+
}
|
|
1137
1065
|
pluginConfiguration={this.getPluginConfiguration()}
|
|
1138
1066
|
controller={this.props.controller}
|
|
1139
1067
|
>
|