@applicaster/quick-brick-player 16.0.0-rc.13 → 16.0.0-rc.131
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 +6 -6
- package/src/Player/AudioLayer/AudioDescription.tsx +46 -11
- package/src/Player/AudioLayer/AudioPlayerWrapper.tsx +39 -49
- package/src/Player/AudioLayer/Layout/Controls/__tests__/utils.test.ts +135 -0
- package/src/Player/AudioLayer/Layout/Controls/index.tsx +34 -14
- package/src/Player/AudioLayer/Layout/Controls/utils.ts +40 -0
- package/src/Player/AudioLayer/Layout/DockedControls/__tests__/controlButtons.test.ts +86 -0
- package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +2 -14
- package/src/Player/AudioLayer/Layout/MobileLayout.tsx +0 -4
- package/src/Player/AudioLayer/Layout/TabletLandscapeLayout.tsx +0 -4
- package/src/Player/AudioLayer/Layout/TabletPortraitLayout.tsx +0 -4
- package/src/Player/AudioLayer/Layout/TransportInfo/__tests__/index.test.tsx +257 -0
- package/src/Player/AudioLayer/Layout/TransportInfo/index.tsx +69 -8
- package/src/Player/AudioLayer/PlaylistNavigationController.ts +354 -0
- package/src/Player/AudioLayer/SleepTimerManager.ts +6 -2
- package/src/Player/AudioLayer/SpeedManager.ts +5 -1
- package/src/Player/AudioLayer/__tests__/AudioDescription.test.tsx +147 -0
- package/src/Player/AudioLayer/__tests__/AudioPlayerWrapper.test.tsx +130 -0
- package/src/Player/AudioLayer/__tests__/PlaylistNavigationController.test.ts +528 -0
- package/src/Player/AudioLayer/__tests__/SleepTimerManager.test.ts +78 -0
- package/src/Player/AudioLayer/__tests__/SpeedManager.test.ts +57 -0
- package/src/Player/AudioLayer/__tests__/playerActions.test.ts +369 -0
- package/src/Player/AudioLayer/__tests__/usePlaylistNavigation.test.ts +539 -0
- package/src/Player/AudioLayer/playerActions.ts +294 -0
- package/src/Player/AudioLayer/usePlaylistNavigation.ts +148 -0
- package/src/Player/AudioLayer/useSleepTimerModal.ts +20 -57
- package/src/Player/PlayerModal/VideoPlayerModal.tsx +18 -1
- package/src/Player/PlayerModal/__tests__/VideoPlayerModal.test.tsx +160 -0
- package/src/Player/__tests__/getNativeProps.test.ts +115 -0
- package/src/Player/__tests__/mobileControls.test.ts +35 -0
- package/src/Player/__tests__/onTracksChanged.test.ts +192 -0
- package/src/Player/__tests__/toNativeMetadata.test.ts +77 -0
- package/src/Player/index.tsx +225 -52
- package/src/Player/mobileControls.ts +7 -0
- package/src/Player/mobileControls.web.ts +10 -0
- package/src/logger.ts +3 -5
- package/src/Player/AudioLayer/components/SleepTimerModalHeader/SleepTimerModalHeader.tsx +0 -66
- package/src/Player/AudioLayer/components/SleepTimerModalHeader/index.ts +0 -1
package/src/Player/index.tsx
CHANGED
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import * as R from "ramda";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Dimensions,
|
|
10
|
+
findNodeHandle,
|
|
11
|
+
StyleSheet,
|
|
12
|
+
View,
|
|
13
|
+
ViewStyle,
|
|
14
|
+
} from "react-native";
|
|
9
15
|
|
|
10
|
-
import TransportControlsMobile, {
|
|
11
|
-
ErrorOverlay,
|
|
12
|
-
} from "@applicaster/quick-brick-mobile-transport-controls";
|
|
13
16
|
import TransportControlsTV, {
|
|
14
17
|
ErrorOverlay as TVErrorOverlay,
|
|
15
18
|
} from "@applicaster/quick-brick-tv-transport-controls";
|
|
@@ -27,11 +30,11 @@ import {
|
|
|
27
30
|
PlayerDetails,
|
|
28
31
|
PlayerWrapper,
|
|
29
32
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
|
|
33
|
+
import { getVerticalColumnWidth } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/playerWrapperUtils";
|
|
30
34
|
|
|
31
35
|
import { PlayNextOverlay } from "./PlayNextOverlay";
|
|
32
36
|
import { PlayerImageBackground } from "@applicaster/zapp-react-native-ui-components/Components/PlayerImageBackground";
|
|
33
37
|
|
|
34
|
-
import { GENERAL_EVENT } from "@applicaster/zapp-react-native-utils/analyticsUtils/events";
|
|
35
38
|
import { parseLanguageTracks } from "@applicaster/zapp-react-native-utils/playerUtils/configurationUtils";
|
|
36
39
|
import { DEFAULT_COLORS, SEEK_TIME } from "../utils/const";
|
|
37
40
|
import { logger, getScreenAspectRatio } from "../utils";
|
|
@@ -41,7 +44,6 @@ import { getAllAccessibilityProps } from "@applicaster/zapp-react-native-utils/c
|
|
|
41
44
|
import { PlayNextData } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
|
|
42
45
|
import { getTargetScreenDataFromEntry } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useTargetScreenData";
|
|
43
46
|
import { PlayerAnalyticsManager } from "@applicaster/zapp-react-native-utils/analyticsUtils/PlayerAnalyticsManager";
|
|
44
|
-
import { PlayerAnalyticsTrackerI } from "@applicaster/zapp-react-native-utils/analyticsUtils/playerAnalyticsTracker";
|
|
45
47
|
|
|
46
48
|
import { RNPlayerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/nativePlayerManager";
|
|
47
49
|
import {
|
|
@@ -49,12 +51,17 @@ import {
|
|
|
49
51
|
isAudioItem as isAudioItemUtil,
|
|
50
52
|
isInlineTV as isInlineTVUtil,
|
|
51
53
|
} from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
54
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
52
55
|
|
|
53
56
|
import { TVPlayerView } from "./PlayerView/TVPlayerView";
|
|
54
57
|
import PlayerModal, { VideoPlayerModal } from "./PlayerModal";
|
|
55
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
DockedControls,
|
|
60
|
+
ErrorOverlay,
|
|
61
|
+
TransportControlsMobile,
|
|
62
|
+
} from "./mobileControls";
|
|
56
63
|
import { FlexImage } from "./AudioLayer/Layout/PlayerImage/FlexImage";
|
|
57
|
-
import { PlayerError } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/
|
|
64
|
+
import { PlayerError } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/const";
|
|
58
65
|
|
|
59
66
|
const isTvOS = isTvOSPlatform();
|
|
60
67
|
|
|
@@ -71,6 +78,60 @@ const styles = StyleSheet.create({
|
|
|
71
78
|
flexImage: { height: "100%", aspectRatio: 1, flex: -1 },
|
|
72
79
|
});
|
|
73
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Coerces the resolver's `Option<string | number>` result into what the
|
|
83
|
+
* native bridge expects: a string, or `undefined` when there is nothing to
|
|
84
|
+
* send.
|
|
85
|
+
*/
|
|
86
|
+
const toNativeTextProp = (
|
|
87
|
+
value: Option<string | number>
|
|
88
|
+
): string | undefined =>
|
|
89
|
+
value === null || value === undefined ? undefined : String(value);
|
|
90
|
+
|
|
91
|
+
export type NativePlayerMetadata = {
|
|
92
|
+
title: string | undefined;
|
|
93
|
+
subtitle: string | undefined;
|
|
94
|
+
imageUrl: string | undefined;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Adapts the player's resolved Title/Subtitle into the `metadata` object the
|
|
99
|
+
* *native* view receives.
|
|
100
|
+
*
|
|
101
|
+
* The resolution itself (dot-path / key-set logic, entry fallback) does not
|
|
102
|
+
* happen here - the player manager resolves it and publishes it on its content
|
|
103
|
+
* channel (`player.getContent()`). This function only coerces that value's
|
|
104
|
+
* `Option<string | number>` shape into what the native bridge needs: a string,
|
|
105
|
+
* or `undefined` when there is nothing to send.
|
|
106
|
+
*
|
|
107
|
+
* Travels as one `metadata` object rather than two flat props so native has a
|
|
108
|
+
* single place to look for player-facing text, and so adding a field later
|
|
109
|
+
* does not widen the bridge's prop surface again.
|
|
110
|
+
*
|
|
111
|
+
* This intentionally does not touch `entry` - analytics and the downloads
|
|
112
|
+
* feature read `entry.title` / `entry.summary` directly and must keep
|
|
113
|
+
* seeing the original feed values (the downloads feature requires the
|
|
114
|
+
* original entry title). The resolved (possibly customer-configured) text
|
|
115
|
+
* travels in `metadata` instead.
|
|
116
|
+
*
|
|
117
|
+
* Exported as a plain function (rather than inlined as a class method) so
|
|
118
|
+
* it can be unit tested directly without rendering the ~37KB `VideoPlayer`
|
|
119
|
+
* class component.
|
|
120
|
+
*/
|
|
121
|
+
export const toNativeMetadata = (
|
|
122
|
+
content: Option<{
|
|
123
|
+
title: Option<string | number>;
|
|
124
|
+
summary: Option<string | number>;
|
|
125
|
+
imageUrl?: Option<string>;
|
|
126
|
+
}>
|
|
127
|
+
): NativePlayerMetadata => ({
|
|
128
|
+
title: toNativeTextProp(content?.title),
|
|
129
|
+
subtitle: toNativeTextProp(content?.summary),
|
|
130
|
+
// Already a string when present; coerced through the same helper so an
|
|
131
|
+
// empty or nullish value reaches native as `undefined` rather than "".
|
|
132
|
+
imageUrl: toNativeTextProp(content?.imageUrl),
|
|
133
|
+
});
|
|
134
|
+
|
|
74
135
|
type VideoPlayerProps = QuickBrickPlayer.PlayerProps & {
|
|
75
136
|
isCasting?: boolean;
|
|
76
137
|
playNextData?: PlayNextData;
|
|
@@ -96,6 +157,38 @@ type VideoPlayerProps = QuickBrickPlayer.PlayerProps & {
|
|
|
96
157
|
children?: React.ReactNode;
|
|
97
158
|
};
|
|
98
159
|
|
|
160
|
+
/**
|
|
161
|
+
* `textTrackId`/`audioTrackId` are both the value the native player *reports* as
|
|
162
|
+
* currently selected AND the *controlled prop* that drives native selection.
|
|
163
|
+
* Because of that dual role, reflecting a reported value straight back down turns
|
|
164
|
+
* a status update into a command.
|
|
165
|
+
*
|
|
166
|
+
* The native player can momentarily report "nothing selected" (index -1, which
|
|
167
|
+
* `parseLanguageTracks` maps to `undefined`) during normal fMP4/ABR segment
|
|
168
|
+
* transitions. Pushing that back down as a "disable"/"clear" command flips native
|
|
169
|
+
* state, which emits a fresh onTracksChanged, which we would echo again — an
|
|
170
|
+
* infinite feedback loop.
|
|
171
|
+
*
|
|
172
|
+
* Keep the current selection when the reported value is a transient drop and the
|
|
173
|
+
* chosen track is still available. A genuine user "Off"/change already updates the
|
|
174
|
+
* controlled state first, so this only ignores unsolicited native status blips.
|
|
175
|
+
*/
|
|
176
|
+
const resolveReportedTrackId = (
|
|
177
|
+
reportedId: string | null | undefined,
|
|
178
|
+
currentId: string | null,
|
|
179
|
+
tracks: { id: string }[] = []
|
|
180
|
+
): string | null => {
|
|
181
|
+
if (reportedId) {
|
|
182
|
+
return reportedId;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (currentId && tracks.some((track) => track?.id === currentId)) {
|
|
186
|
+
return currentId;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return null;
|
|
190
|
+
};
|
|
191
|
+
|
|
99
192
|
export default class VideoPlayer extends React.Component<
|
|
100
193
|
VideoPlayerProps,
|
|
101
194
|
QuickBrickPlayer.NativePlayerState & {
|
|
@@ -164,20 +257,10 @@ export default class VideoPlayer extends React.Component<
|
|
|
164
257
|
nativePlayerIsReady: false,
|
|
165
258
|
};
|
|
166
259
|
|
|
167
|
-
private _tracker: PlayerAnalyticsTrackerI;
|
|
168
|
-
get analyticsTracker() {
|
|
169
|
-
if (!this._tracker) {
|
|
170
|
-
this._tracker = PlayerAnalyticsManager.getInstance().getTracker(
|
|
171
|
-
this.props.playerId
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return this._tracker;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
260
|
constructor(props) {
|
|
179
261
|
super(props);
|
|
180
262
|
this.onVideoLoadCalled = false; // android
|
|
263
|
+
PlayerAnalyticsManager.getInstance();
|
|
181
264
|
|
|
182
265
|
this.takeParentStyle = isWeb()
|
|
183
266
|
? { width: "100%", flex: "1 1 auto", objectFit: "contain" }
|
|
@@ -191,9 +274,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
191
274
|
componentWillUnmount() {
|
|
192
275
|
this.playbackStarted = false;
|
|
193
276
|
|
|
194
|
-
this.analyticsTracker.handleAnalyticEvent(GENERAL_EVENT.session_end);
|
|
195
|
-
this.onPlayerClosed();
|
|
196
|
-
|
|
197
277
|
if (isAndroidPlatform()) {
|
|
198
278
|
this.disablePiP();
|
|
199
279
|
}
|
|
@@ -201,7 +281,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
201
281
|
|
|
202
282
|
componentDidMount() {
|
|
203
283
|
this.playbackStarted = false;
|
|
204
|
-
this.onPlayerPresented();
|
|
205
284
|
}
|
|
206
285
|
|
|
207
286
|
shouldComponentUpdate(nextProps) {
|
|
@@ -328,6 +407,22 @@ export default class VideoPlayer extends React.Component<
|
|
|
328
407
|
RNPlayerManager?.[this.playerPluginId]?.stopBackgroundPlayback?.();
|
|
329
408
|
};
|
|
330
409
|
|
|
410
|
+
command = (command: string, userInfo?: Record<string, any>) => {
|
|
411
|
+
if (
|
|
412
|
+
this.isReactNativeMethodsSupported() &&
|
|
413
|
+
RNPlayerManager?.[this.playerPluginId]?.command &&
|
|
414
|
+
this._root
|
|
415
|
+
) {
|
|
416
|
+
const node = findNodeHandle(this._root);
|
|
417
|
+
|
|
418
|
+
if (!node) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
RNPlayerManager?.[this.playerPluginId]?.command(node, command, userInfo);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
331
426
|
forward = (seekTime = SEEK_TIME) => {
|
|
332
427
|
const currentTime = this.state.currentTime;
|
|
333
428
|
|
|
@@ -445,14 +540,6 @@ export default class VideoPlayer extends React.Component<
|
|
|
445
540
|
});
|
|
446
541
|
};
|
|
447
542
|
|
|
448
|
-
onPlayerPresented = () => {
|
|
449
|
-
this.analyticsTracker?.handleAnalyticEvent(GENERAL_EVENT.player_presented);
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
onPlayerClosed = () => {
|
|
453
|
-
this.analyticsTracker?.handleAnalyticEvent(GENERAL_EVENT.player_closed);
|
|
454
|
-
};
|
|
455
|
-
|
|
456
543
|
onVideoEnd = () => {
|
|
457
544
|
this.setState({ displayOverlay: !this.state.displayOverlay }, () => {
|
|
458
545
|
if (this.state?.displayOverlay) {
|
|
@@ -473,6 +560,10 @@ export default class VideoPlayer extends React.Component<
|
|
|
473
560
|
return this.props?.listener?.onError(newError);
|
|
474
561
|
};
|
|
475
562
|
|
|
563
|
+
onRemoteCommand = ({ nativeEvent = null }) => {
|
|
564
|
+
this.props?.listener?.onRemoteCommand?.(nativeEvent);
|
|
565
|
+
};
|
|
566
|
+
|
|
476
567
|
onPlayerPause = ({ nativeEvent = null }) => {
|
|
477
568
|
this.setState({ paused: true });
|
|
478
569
|
this.props?.listener?.onPlayerPause(nativeEvent);
|
|
@@ -482,7 +573,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
482
573
|
const { isAd, resume } = this.state;
|
|
483
574
|
const isNotAnAd = !isAd;
|
|
484
575
|
this.setState({ paused: false });
|
|
485
|
-
this.props?.listener?.onPlayerResume?.(
|
|
576
|
+
this.props?.listener?.onPlayerResume?.(nativeEvent);
|
|
486
577
|
|
|
487
578
|
if (isNotAnAd && !resume) {
|
|
488
579
|
this.setState({ resume: true });
|
|
@@ -667,20 +758,50 @@ export default class VideoPlayer extends React.Component<
|
|
|
667
758
|
const { textTracks, audioTracks, audioTrackId, textTrackId } =
|
|
668
759
|
parseLanguageTracks(nativeEvent);
|
|
669
760
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
761
|
+
// Resolve the reported selection against the current controlled state so a
|
|
762
|
+
// transient native "nothing selected" doesn't get echoed back as a command
|
|
763
|
+
// and re-trigger native selection (infinite loop, see resolveReportedTrackId).
|
|
764
|
+
const nextAudioTrackId = resolveReportedTrackId(
|
|
765
|
+
audioTrackId,
|
|
766
|
+
this.state.audioTrackId,
|
|
767
|
+
audioTracks
|
|
768
|
+
);
|
|
769
|
+
|
|
770
|
+
const nextTextTrackId = resolveReportedTrackId(
|
|
771
|
+
textTrackId,
|
|
772
|
+
this.state.textTrackId,
|
|
773
|
+
textTracks
|
|
683
774
|
);
|
|
775
|
+
|
|
776
|
+
const notifyListener = () =>
|
|
777
|
+
this.props?.listener?.onTracksChanged?.({
|
|
778
|
+
textTracks,
|
|
779
|
+
audioTracks,
|
|
780
|
+
audioTrackId: nextAudioTrackId,
|
|
781
|
+
textTrackId: nextTextTrackId,
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
// Only update state (and thus re-send the controlled props) on a real change.
|
|
785
|
+
// Re-rendering with identical prop values would otherwise keep the native
|
|
786
|
+
// event/prop echo alive.
|
|
787
|
+
const stateChanges: {
|
|
788
|
+
audioTrackId?: string | null;
|
|
789
|
+
textTrackId?: string | null;
|
|
790
|
+
} = {};
|
|
791
|
+
|
|
792
|
+
if (nextAudioTrackId !== this.state.audioTrackId) {
|
|
793
|
+
stateChanges.audioTrackId = nextAudioTrackId;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
if (nextTextTrackId !== this.state.textTrackId) {
|
|
797
|
+
stateChanges.textTrackId = nextTextTrackId;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
if (Object.keys(stateChanges).length > 0) {
|
|
801
|
+
this.setState(stateChanges as any, notifyListener);
|
|
802
|
+
} else {
|
|
803
|
+
notifyListener();
|
|
804
|
+
}
|
|
684
805
|
};
|
|
685
806
|
|
|
686
807
|
onVideoProgress = ({ nativeEvent }) => {
|
|
@@ -977,6 +1098,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
977
1098
|
onPlayerResume: this.onPlayerResume,
|
|
978
1099
|
onPlayerSeekComplete: this.onPlayerSeekComplete,
|
|
979
1100
|
onPlayerSeekStart: this.onPlayerSeekStart,
|
|
1101
|
+
onRemoteCommand: this.onRemoteCommand,
|
|
980
1102
|
};
|
|
981
1103
|
|
|
982
1104
|
const lifecycleEvents = {
|
|
@@ -1096,6 +1218,15 @@ export default class VideoPlayer extends React.Component<
|
|
|
1096
1218
|
const liveCatchUpEnabled =
|
|
1097
1219
|
this.props.pluginConfiguration?.liveCatchUpEnabled;
|
|
1098
1220
|
|
|
1221
|
+
// Look the player up by id rather than using the active player: these
|
|
1222
|
+
// props are handed to this component's own native player view, so they
|
|
1223
|
+
// must describe that player's content even while a cast session is
|
|
1224
|
+
// running (during which `usePlayer` swaps React consumers over to the
|
|
1225
|
+
// casting receiver).
|
|
1226
|
+
const metadata = toNativeMetadata(
|
|
1227
|
+
playerManager.getPlayerWithId(this.props.playerId)?.getContent()
|
|
1228
|
+
);
|
|
1229
|
+
|
|
1099
1230
|
const nativeProps = {
|
|
1100
1231
|
rate: undefined,
|
|
1101
1232
|
entry,
|
|
@@ -1114,6 +1245,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
1114
1245
|
liveCatchUpEnabled,
|
|
1115
1246
|
playerId: this.props.playerId,
|
|
1116
1247
|
pictureInPictureEnabled,
|
|
1248
|
+
metadata,
|
|
1117
1249
|
seekStep:
|
|
1118
1250
|
(this.props.pluginConfiguration?.seek_duration || SEEK_TIME) * 1000,
|
|
1119
1251
|
accessibilityProps: getAllAccessibilityProps(
|
|
@@ -1170,10 +1302,15 @@ export default class VideoPlayer extends React.Component<
|
|
|
1170
1302
|
return null;
|
|
1171
1303
|
}
|
|
1172
1304
|
|
|
1173
|
-
const
|
|
1305
|
+
const isTvPlatform = isTV();
|
|
1306
|
+
|
|
1307
|
+
const TransportControls = isTvPlatform
|
|
1174
1308
|
? TransportControlsTV
|
|
1175
1309
|
: TransportControlsMobile;
|
|
1176
1310
|
|
|
1311
|
+
// The mobile and TV transport controls read Title/Subtitle from the
|
|
1312
|
+
// player manager's content channel (via `usePlayerContent`) instead of
|
|
1313
|
+
// receiving them as props.
|
|
1177
1314
|
const needToShowDefaultControls = !(
|
|
1178
1315
|
(controls && !castAction?.state?.connected) ||
|
|
1179
1316
|
this.getPlayNextData()
|
|
@@ -1199,10 +1336,16 @@ export default class VideoPlayer extends React.Component<
|
|
|
1199
1336
|
controlsAlwaysVisible={castAction?.state?.connected}
|
|
1200
1337
|
playNextData={this.getPlayNextData()}
|
|
1201
1338
|
needToShowDefaultControls={needToShowDefaultControls}
|
|
1339
|
+
vertical={this.isVerticalPlayer()}
|
|
1202
1340
|
/>
|
|
1203
1341
|
) : null;
|
|
1204
1342
|
};
|
|
1205
1343
|
|
|
1344
|
+
// Single source for the vertical player flag: used by the player wrapper and the transport controls
|
|
1345
|
+
isVerticalPlayer = (): boolean => {
|
|
1346
|
+
return this.getPluginConfiguration()?.vertical_video_player || false;
|
|
1347
|
+
};
|
|
1348
|
+
|
|
1206
1349
|
// Helper method for inline TV check
|
|
1207
1350
|
isInlineTV = () => {
|
|
1208
1351
|
const screenData = getTargetScreenDataFromEntry(this.props.playableItem);
|
|
@@ -1233,6 +1376,8 @@ export default class VideoPlayer extends React.Component<
|
|
|
1233
1376
|
const isFullScreenAudioPlayer =
|
|
1234
1377
|
pluginConfiguration?.full_screen_audio_player || false;
|
|
1235
1378
|
|
|
1379
|
+
const vertical = this.isVerticalPlayer();
|
|
1380
|
+
|
|
1236
1381
|
const sharedWrapperViewProps = {
|
|
1237
1382
|
style,
|
|
1238
1383
|
entry,
|
|
@@ -1240,6 +1385,7 @@ export default class VideoPlayer extends React.Component<
|
|
|
1240
1385
|
docked,
|
|
1241
1386
|
isModal,
|
|
1242
1387
|
pip: piped,
|
|
1388
|
+
vertical,
|
|
1243
1389
|
layoutState: {
|
|
1244
1390
|
inline,
|
|
1245
1391
|
docked,
|
|
@@ -1253,8 +1399,31 @@ export default class VideoPlayer extends React.Component<
|
|
|
1253
1399
|
|
|
1254
1400
|
const shouldRenderNativePlayer = !isCasting || this.supportNativeCast;
|
|
1255
1401
|
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1402
|
+
const isVerticalInlineTabletLandscape =
|
|
1403
|
+
vertical &&
|
|
1404
|
+
inline &&
|
|
1405
|
+
isModal &&
|
|
1406
|
+
!piped &&
|
|
1407
|
+
getIsTablet() &&
|
|
1408
|
+
!isTabletPortrait;
|
|
1409
|
+
|
|
1410
|
+
// Vertical inline on a landscape tablet fills the column height. The
|
|
1411
|
+
// minimise animation and the docked slot both use this ratio, so it has to
|
|
1412
|
+
// describe that box, not 16:9, and both sides have to come from the same
|
|
1413
|
+
// window the layout measures -- getTabletWidth resolves percentages
|
|
1414
|
+
// against the device screen, which is wider than the app in split view.
|
|
1415
|
+
const verticalColumnWidth = isVerticalInlineTabletLandscape
|
|
1416
|
+
? getVerticalColumnWidth(
|
|
1417
|
+
Dimensions.get("window").width,
|
|
1418
|
+
pluginConfiguration.tablet_landscape_sidebar_width
|
|
1419
|
+
)
|
|
1420
|
+
: undefined;
|
|
1421
|
+
|
|
1422
|
+
const aspectRatio = isVerticalInlineTabletLandscape
|
|
1423
|
+
? verticalColumnWidth / Dimensions.get("window").height
|
|
1424
|
+
: !inline && isModal && !piped
|
|
1425
|
+
? getScreenAspectRatio()
|
|
1426
|
+
: 16 / 9;
|
|
1258
1427
|
|
|
1259
1428
|
const audioPlayerProps = {
|
|
1260
1429
|
ref: this._assignRoot,
|
|
@@ -1295,10 +1464,14 @@ export default class VideoPlayer extends React.Component<
|
|
|
1295
1464
|
fullscreen={fullscreen}
|
|
1296
1465
|
modal
|
|
1297
1466
|
style={{
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1467
|
+
// The modal freezes this as the player width, so it has to be the
|
|
1468
|
+
// same column the aspect ratio above describes.
|
|
1469
|
+
tabletLandscapeWidth:
|
|
1470
|
+
verticalColumnWidth ??
|
|
1471
|
+
getTabletWidth(
|
|
1472
|
+
this.getPluginConfiguration().tablet_landscape_sidebar_width,
|
|
1473
|
+
style
|
|
1474
|
+
),
|
|
1302
1475
|
width: style.width,
|
|
1303
1476
|
height: style.height,
|
|
1304
1477
|
}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Controls only the mobile player renders (Player's renderMobile path). Web builds resolve mobileControls.web.ts.
|
|
2
|
+
export {
|
|
3
|
+
default as TransportControlsMobile,
|
|
4
|
+
ErrorOverlay,
|
|
5
|
+
} from "@applicaster/quick-brick-mobile-transport-controls";
|
|
6
|
+
|
|
7
|
+
export { DockedControls } from "./AudioLayer/Layout/DockedControls";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Web builds always render the TV player: Player renders `isTV() ? renderTV() : renderMobile()`, and isTV() is true on
|
|
2
|
+
// every web platform. The mobile controls are never rendered there, so web bundles get empty stand-ins and leave the
|
|
3
|
+
// mobile transport controls package out.
|
|
4
|
+
const NotRenderedOnWeb = () => null;
|
|
5
|
+
|
|
6
|
+
export const TransportControlsMobile = NotRenderedOnWeb;
|
|
7
|
+
|
|
8
|
+
export const ErrorOverlay = NotRenderedOnWeb;
|
|
9
|
+
|
|
10
|
+
export const DockedControls = NotRenderedOnWeb;
|
package/src/logger.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
export const Subsystem = "plugins/zapp-react-native-default-player";
|
|
3
|
+
export const Subsystem = "player";
|
|
6
4
|
|
|
7
5
|
export const Categories = {
|
|
8
6
|
PLAYER: "player",
|
|
@@ -19,7 +17,7 @@ export function createLogger({ category = "", subsystem }) {
|
|
|
19
17
|
return null;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
const logger =
|
|
20
|
+
const logger = subsystemLogger(Subsystem, category);
|
|
23
21
|
loggers[subsystem] = logger;
|
|
24
22
|
|
|
25
23
|
return logger;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ModalHeader } from "@applicaster/zapp-react-native-ui-components/Components/ModalComponent/Header";
|
|
3
|
-
import { isNil } from "@applicaster/zapp-react-native-utils/utils";
|
|
4
|
-
|
|
5
|
-
const formatTime = (milliseconds: number) => {
|
|
6
|
-
const totalSeconds = Math.floor(milliseconds / 1000);
|
|
7
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
8
|
-
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
9
|
-
const seconds = totalSeconds % 60;
|
|
10
|
-
|
|
11
|
-
if (milliseconds < 3600000) {
|
|
12
|
-
return `${minutes.toString().padStart(2, "0")}:${seconds
|
|
13
|
-
.toString()
|
|
14
|
-
.padStart(2, "0")}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return `${hours.toString().padStart(2, "0")}:${minutes
|
|
18
|
-
.toString()
|
|
19
|
-
.padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const SleepTimerModalHeader = ({
|
|
23
|
-
summary,
|
|
24
|
-
...props
|
|
25
|
-
}: {
|
|
26
|
-
summary?: string;
|
|
27
|
-
}) => {
|
|
28
|
-
const sleepTimerDate = +summary;
|
|
29
|
-
|
|
30
|
-
const [timeLeft, setTimeLeft] = React.useState(
|
|
31
|
-
sleepTimerDate !== 0 ? sleepTimerDate - Date.now() : 0
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const showCounter = React.useMemo(() => sleepTimerDate > 0, [sleepTimerDate]);
|
|
35
|
-
|
|
36
|
-
React.useLayoutEffect(() => {
|
|
37
|
-
if (showCounter && sleepTimerDate !== 0) {
|
|
38
|
-
setTimeLeft(sleepTimerDate - Date.now());
|
|
39
|
-
|
|
40
|
-
const intervalId = setInterval(() => {
|
|
41
|
-
setTimeLeft(() => {
|
|
42
|
-
const newTimeLeft = sleepTimerDate - Date.now();
|
|
43
|
-
|
|
44
|
-
if (newTimeLeft <= 0) {
|
|
45
|
-
clearInterval(intervalId);
|
|
46
|
-
|
|
47
|
-
return 0;
|
|
48
|
-
} else {
|
|
49
|
-
return newTimeLeft;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}, 1000);
|
|
53
|
-
|
|
54
|
-
return () => clearInterval(intervalId);
|
|
55
|
-
} else {
|
|
56
|
-
setTimeLeft(0);
|
|
57
|
-
}
|
|
58
|
-
}, [sleepTimerDate, showCounter]);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<ModalHeader
|
|
62
|
-
summary={!isNil(summary) ? formatTime(timeLeft) : summary}
|
|
63
|
-
{...(props as any)}
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./SleepTimerModalHeader";
|