@applicaster/quick-brick-player 14.0.0-rc.10 → 14.0.0-rc.12
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 +5 -5
- package/src/Player/AudioLayer/Layout/PlayerImage/AnimatedImage.tsx +2 -6
- package/src/Player/AudioLayer/Layout/PlayerImage/FlexImage.tsx +2 -5
- package/src/Player/AudioLayer/Layout/PlayerImage/hooks/index.ts +2 -0
- package/src/Player/AudioLayer/Layout/PlayerImage/hooks/useBackgroundImage.ts +46 -0
- package/src/Player/PlayerView/GenericTVPlayerView.tsx +43 -0
- package/src/Player/PlayerView/TVPlayerView.tsx +26 -0
- package/src/Player/PlayerView/TvOSPlayerView.tsx +51 -0
- package/src/Player/PlayerView/types.ts +42 -0
- package/src/Player/index.tsx +27 -83
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "14.0.0-rc.
|
|
3
|
+
"version": "14.0.0-rc.12",
|
|
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": "
|
|
38
|
+
"@applicaster/quick-brick-mobile-transport-controls": "14.0.0-rc.11",
|
|
39
39
|
"@applicaster/quick-brick-tv-transport-controls": "14.0.0-rc.7",
|
|
40
|
-
"@applicaster/zapp-react-native-tvos-app": "14.0.0-rc.
|
|
41
|
-
"@applicaster/zapp-react-native-ui-components": "14.0.0-rc.
|
|
42
|
-
"@applicaster/zapp-react-native-utils": "14.0.0-rc.
|
|
40
|
+
"@applicaster/zapp-react-native-tvos-app": "14.0.0-rc.12",
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components": "14.0.0-rc.12",
|
|
42
|
+
"@applicaster/zapp-react-native-utils": "14.0.0-rc.12",
|
|
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,
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
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";
|
|
12
11
|
|
|
13
|
-
import { useChangePlayerState } from "./hooks";
|
|
12
|
+
import { useChangePlayerState, useBackgroundImage } from "./hooks";
|
|
14
13
|
|
|
15
14
|
const styles = StyleSheet.create({
|
|
16
15
|
container: {
|
|
@@ -30,10 +29,7 @@ type Props = PropsWithChildren<{
|
|
|
30
29
|
export const AnimatedImage = ({ entry, style, imageWidth, docked }: Props) => {
|
|
31
30
|
const heightAnim = React.useRef(new Animated.Value(imageWidth)).current;
|
|
32
31
|
|
|
33
|
-
const source =
|
|
34
|
-
() => ({ uri: imageSrcFromMediaItem(entry, undefined) }),
|
|
35
|
-
[entry]
|
|
36
|
-
);
|
|
32
|
+
const source = useBackgroundImage({ entry });
|
|
37
33
|
|
|
38
34
|
const { minimisedHeight } = useModalAnimationContext();
|
|
39
35
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Image, ImageStyle } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useBackgroundImage } from "./hooks";
|
|
5
5
|
|
|
6
6
|
type Props = {
|
|
7
7
|
entry: ZappEntry;
|
|
@@ -9,10 +9,7 @@ type Props = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const FlexImage = ({ entry, style }: Props) => {
|
|
12
|
-
const source =
|
|
13
|
-
() => ({ uri: imageSrcFromMediaItem(entry, undefined) }),
|
|
14
|
-
[entry]
|
|
15
|
-
);
|
|
12
|
+
const source = useBackgroundImage({ entry });
|
|
16
13
|
|
|
17
14
|
if (!source) return null;
|
|
18
15
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useZStore } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
3
|
+
import { getBackgroundImage } from "@applicaster/zapp-react-native-utils/audioPlayerUtils";
|
|
4
|
+
|
|
5
|
+
const audioPlayerImageKeySelector = (config) => config?.audio_player_image_key;
|
|
6
|
+
|
|
7
|
+
const audioPlayerBackgroundImageSelector = (config) =>
|
|
8
|
+
config?.audio_player_background_image;
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
entry: ZappEntry;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type Return = {
|
|
15
|
+
uri: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const useBackgroundImage = ({ entry }: Props): Return => {
|
|
19
|
+
const configuration = useZStore("playerConfiguration");
|
|
20
|
+
|
|
21
|
+
const audio_player_image_key = configuration(audioPlayerImageKeySelector);
|
|
22
|
+
|
|
23
|
+
const audio_player_background_image = configuration(
|
|
24
|
+
audioPlayerBackgroundImageSelector
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const pluginConfiguration = React.useMemo(
|
|
28
|
+
() => ({
|
|
29
|
+
audio_player_image_key,
|
|
30
|
+
audio_player_background_image,
|
|
31
|
+
}),
|
|
32
|
+
[audio_player_image_key, audio_player_background_image]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const source = React.useMemo(
|
|
36
|
+
() => ({
|
|
37
|
+
uri: getBackgroundImage({
|
|
38
|
+
entry,
|
|
39
|
+
plugin_configuration: pluginConfiguration,
|
|
40
|
+
}),
|
|
41
|
+
}),
|
|
42
|
+
[entry, pluginConfiguration]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return source;
|
|
46
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
inline,
|
|
17
|
+
}) => {
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
{type === "audio" && inline ? (
|
|
21
|
+
<AudioPlayer
|
|
22
|
+
audio_item={entry}
|
|
23
|
+
plugin_configuration={pluginConfiguration}
|
|
24
|
+
{...audioPlayerProps}
|
|
25
|
+
/>
|
|
26
|
+
) : null}
|
|
27
|
+
<PlayerComponent
|
|
28
|
+
pluginConfiguration={pluginConfiguration}
|
|
29
|
+
{...playerProps}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</PlayerComponent>
|
|
33
|
+
{transportControls}
|
|
34
|
+
{playNextProps.playNextData ? (
|
|
35
|
+
<PlayNextOverlay
|
|
36
|
+
item={entry}
|
|
37
|
+
pluginConfiguration={pluginConfiguration}
|
|
38
|
+
{...playNextProps}
|
|
39
|
+
/>
|
|
40
|
+
) : null}
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -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;
|
package/src/Player/index.tsx
CHANGED
|
@@ -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";
|
|
@@ -46,6 +44,8 @@ import {
|
|
|
46
44
|
isInlineTV as isInlineTVUtil,
|
|
47
45
|
} from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
48
46
|
|
|
47
|
+
import { TVPlayerView } from "./PlayerView/TVPlayerView";
|
|
48
|
+
|
|
49
49
|
const styles = StyleSheet.create({
|
|
50
50
|
container: { flex: 1 },
|
|
51
51
|
playerContainerBlack: { backgroundColor: DEFAULT_COLORS.black },
|
|
@@ -55,7 +55,6 @@ const styles = StyleSheet.create({
|
|
|
55
55
|
position: "absolute",
|
|
56
56
|
zIndex: 1,
|
|
57
57
|
},
|
|
58
|
-
audioPlayerSize: { width: "100%", height: "100%" },
|
|
59
58
|
playerSize: { width: "100%", height: "100%" },
|
|
60
59
|
});
|
|
61
60
|
|
|
@@ -66,8 +65,6 @@ const logger = createLogger({
|
|
|
66
65
|
|
|
67
66
|
const isTvOS = isTvOSPlatform();
|
|
68
67
|
|
|
69
|
-
const AUDIO_PLAYER_NATIVE_ID = "audio-player-view";
|
|
70
|
-
|
|
71
68
|
export default class VideoPlayer extends React.Component<
|
|
72
69
|
QuickBrickPlayer.PlayerProps,
|
|
73
70
|
QuickBrickPlayer.NativePlayerState
|
|
@@ -688,53 +685,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
688
685
|
}
|
|
689
686
|
};
|
|
690
687
|
|
|
691
|
-
childrenWithExtensions = () => {
|
|
692
|
-
const { docked, entry, children } = this.props;
|
|
693
|
-
|
|
694
|
-
if (!isTvOS) {
|
|
695
|
-
return children;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
const output = [];
|
|
699
|
-
|
|
700
|
-
// audio-player
|
|
701
|
-
if (isAudioItemUtil(entry)) {
|
|
702
|
-
const { nativePlayerIsReady } = this.state;
|
|
703
|
-
|
|
704
|
-
// we have to wait ready status of native player view, before showing audio_player
|
|
705
|
-
if (nativePlayerIsReady) {
|
|
706
|
-
output.push(
|
|
707
|
-
<View nativeID={AUDIO_PLAYER_NATIVE_ID} key={AUDIO_PLAYER_NATIVE_ID}>
|
|
708
|
-
{children}
|
|
709
|
-
</View>
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
-
} else {
|
|
713
|
-
output.push(children);
|
|
714
|
-
}
|
|
715
|
-
// audio-player
|
|
716
|
-
|
|
717
|
-
// play-next
|
|
718
|
-
if (this.getPlayNextData()) {
|
|
719
|
-
output.push(
|
|
720
|
-
<PlayNextOverlay
|
|
721
|
-
key="play-next-overlay"
|
|
722
|
-
item={entry}
|
|
723
|
-
playerIsDocked={docked}
|
|
724
|
-
pluginConfiguration={this.getPluginConfiguration()}
|
|
725
|
-
playerId={this.props.playerId}
|
|
726
|
-
playNextData={this.getPlayNextData()}
|
|
727
|
-
setNextVideoPreloadThresholdPercentage={
|
|
728
|
-
this.props.setNextVideoPreloadThresholdPercentage
|
|
729
|
-
}
|
|
730
|
-
/>
|
|
731
|
-
);
|
|
732
|
-
}
|
|
733
|
-
// play-next
|
|
734
|
-
|
|
735
|
-
return flatten(output); // prevent possible case with nested array
|
|
736
|
-
};
|
|
737
|
-
|
|
738
688
|
get supportNativeCast() {
|
|
739
689
|
return this.props.controller.supportNativeCast();
|
|
740
690
|
}
|
|
@@ -1141,39 +1091,33 @@ export default class VideoPlayer extends React.Component<
|
|
|
1141
1091
|
const renderTVPlayer = () => {
|
|
1142
1092
|
return (
|
|
1143
1093
|
<View style={this.takeParentStyle} testID={"player-view"}>
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
<this.props.PlayerComponent
|
|
1153
|
-
ref={this._assignRoot}
|
|
1154
|
-
{...nativeEvents}
|
|
1155
|
-
{...nativeProps}
|
|
1156
|
-
listener={this.props.listener}
|
|
1157
|
-
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}
|
|
1158
1101
|
pluginConfiguration={this.getPluginConfiguration()}
|
|
1159
|
-
|
|
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
|
+
}}
|
|
1160
1118
|
>
|
|
1161
|
-
{
|
|
1162
|
-
</
|
|
1163
|
-
|
|
1164
|
-
{renderTransportControls(this.takeParentStyle)}
|
|
1165
|
-
{!isTvOS && (
|
|
1166
|
-
<PlayNextOverlay
|
|
1167
|
-
item={entry}
|
|
1168
|
-
playerIsDocked={docked}
|
|
1169
|
-
pluginConfiguration={this.getPluginConfiguration()}
|
|
1170
|
-
playerId={this.props.playerId}
|
|
1171
|
-
playNextData={this.getPlayNextData()}
|
|
1172
|
-
setNextVideoPreloadThresholdPercentage={
|
|
1173
|
-
this.props.setNextVideoPreloadThresholdPercentage
|
|
1174
|
-
}
|
|
1175
|
-
/>
|
|
1176
|
-
)}
|
|
1119
|
+
{this.props.children}
|
|
1120
|
+
</TVPlayerView>
|
|
1177
1121
|
</View>
|
|
1178
1122
|
);
|
|
1179
1123
|
};
|