@applicaster/zapp-react-native-utils 15.0.0-alpha.1308474364 → 15.0.0-alpha.1346954013
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/actionsExecutor/ActionExecutorContext.tsx +3 -6
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/adsUtils/index.ts +2 -2
- package/analyticsUtils/README.md +1 -1
- package/appUtils/HooksManager/index.ts +10 -10
- package/appUtils/accessibilityManager/__tests__/utils.test.ts +360 -0
- package/appUtils/accessibilityManager/const.ts +4 -0
- package/appUtils/accessibilityManager/hooks.ts +21 -16
- package/appUtils/accessibilityManager/utils.ts +25 -5
- package/appUtils/focusManager/index.ios.ts +8 -2
- package/appUtils/focusManagerAux/utils/index.ts +1 -1
- package/appUtils/focusManagerAux/utils/utils.ios.ts +145 -3
- package/appUtils/keyCodes/keys/keys.web.ts +1 -4
- package/appUtils/orientationHelper.ts +2 -4
- package/appUtils/platform/platformUtils.ts +9 -24
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +94 -4
- package/appUtils/playerManager/OverlayObserver/utils.ts +32 -20
- package/appUtils/playerManager/player.ts +4 -0
- package/appUtils/playerManager/playerNative.ts +29 -16
- package/appUtils/playerManager/usePlayerState.tsx +14 -2
- package/cellUtils/index.ts +1 -8
- package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
- package/focusManager/aux/index.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/player.js +91 -1
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +1 -0
- package/manifestUtils/tvAction/container/index.js +1 -1
- package/package.json +2 -2
- package/playerUtils/usePlayerTTS.ts +6 -4
- package/pluginUtils/index.ts +4 -0
- package/reactHooks/advertising/index.ts +2 -2
- package/reactHooks/debugging/__tests__/index.test.js +4 -4
- package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
- package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +3 -0
- package/reactHooks/feed/__tests__/{useInflatedUrl.test.ts → useInflatedUrl.test.tsx} +62 -7
- package/reactHooks/feed/useEntryScreenId.ts +2 -2
- package/reactHooks/feed/useInflatedUrl.ts +43 -17
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
- package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
- package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
- package/reactHooks/navigation/index.ts +11 -6
- package/reactHooks/navigation/useRoute.ts +8 -6
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
- package/reactHooks/resolvers/useCellResolver.ts +6 -2
- package/reactHooks/resolvers/useComponentResolver.ts +8 -2
- package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +10 -2
- package/reactHooks/screen/useTargetScreenData.ts +4 -2
- package/reactHooks/state/useRivers.ts +1 -1
- package/reactHooks/usePluginConfiguration.ts +2 -2
- package/testUtils/index.tsx +29 -20
- package/utils/__tests__/selectors.test.ts +124 -0
- package/utils/index.ts +10 -0
- package/utils/path.ts +6 -3
- package/utils/pathOr.ts +5 -1
- package/utils/selectors.ts +46 -0
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +34 -11
- package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReplaySubject } from "rxjs";
|
|
2
|
-
import { filter } from "rxjs/operators";
|
|
1
|
+
import { ReplaySubject, Subject } from "rxjs";
|
|
2
|
+
import { filter, switchMap, take, map } from "rxjs/operators";
|
|
3
3
|
import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
|
|
4
4
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
|
|
5
5
|
|
|
@@ -9,6 +9,25 @@ type RegistrationEvent = {
|
|
|
9
9
|
registered: boolean;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
let focusableViewRegistrationSubject$ = new Subject<{
|
|
13
|
+
id: FocusableID;
|
|
14
|
+
groupId: FocusableID;
|
|
15
|
+
}>();
|
|
16
|
+
|
|
17
|
+
let focusableGroupRegistrationSubject$ = new ReplaySubject<{
|
|
18
|
+
id: FocusableID;
|
|
19
|
+
}>();
|
|
20
|
+
|
|
21
|
+
let focusableNativeViewRegistrationSubject$ = new Subject<{
|
|
22
|
+
id: FocusableID;
|
|
23
|
+
groupId: FocusableID;
|
|
24
|
+
}>();
|
|
25
|
+
|
|
26
|
+
let focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
|
|
27
|
+
id: FocusableID;
|
|
28
|
+
groupId: FocusableID;
|
|
29
|
+
}>();
|
|
30
|
+
|
|
12
31
|
const isFocusableButton = (id: Option<FocusableID>): boolean =>
|
|
13
32
|
id && id.includes?.(BUTTON_PREFIX);
|
|
14
33
|
|
|
@@ -22,14 +41,137 @@ export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
|
|
|
22
41
|
)
|
|
23
42
|
);
|
|
24
43
|
|
|
25
|
-
export const
|
|
44
|
+
export const resetFocusableRegistration = () => {
|
|
45
|
+
// complete the old subject so subscribers are notified and resources are freed
|
|
46
|
+
if (!focusableViewRegistrationSubject$.closed) {
|
|
47
|
+
focusableViewRegistrationSubject$.complete();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!focusableGroupRegistrationSubject$.closed) {
|
|
51
|
+
focusableGroupRegistrationSubject$.complete();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!focusableNativeViewRegistrationSubject$.closed) {
|
|
55
|
+
focusableNativeViewRegistrationSubject$.complete();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!focusableNativeGroupRegistrationSubject$.closed) {
|
|
59
|
+
focusableNativeGroupRegistrationSubject$.complete();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
focusableViewRegistrationSubject$ = new Subject<{
|
|
63
|
+
id: FocusableID;
|
|
64
|
+
groupId: FocusableID;
|
|
65
|
+
}>();
|
|
66
|
+
|
|
67
|
+
focusableGroupRegistrationSubject$ = new ReplaySubject<{
|
|
68
|
+
id: FocusableID;
|
|
69
|
+
}>();
|
|
70
|
+
|
|
71
|
+
focusableNativeViewRegistrationSubject$ = new Subject<{
|
|
72
|
+
id: FocusableID;
|
|
73
|
+
groupId: FocusableID;
|
|
74
|
+
}>();
|
|
75
|
+
|
|
76
|
+
focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
|
|
77
|
+
id: FocusableID;
|
|
78
|
+
groupId: FocusableID;
|
|
79
|
+
}>();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
|
|
83
|
+
return focusableNativeViewRegistrationSubject$.pipe(
|
|
84
|
+
filter(
|
|
85
|
+
(focusableNativeView) => focusableNativeView.id === focusableView.id
|
|
86
|
+
),
|
|
87
|
+
take(1),
|
|
88
|
+
switchMap((focusableNativeView) =>
|
|
89
|
+
// start waiting registration of its parent FocusableNativeGroup
|
|
90
|
+
focusableNativeGroupRegistrationSubject$.pipe(
|
|
91
|
+
filter(
|
|
92
|
+
(focusableNativeGroup) =>
|
|
93
|
+
focusableNativeGroup.id === focusableNativeView.groupId
|
|
94
|
+
),
|
|
95
|
+
take(1),
|
|
96
|
+
map((focusableNativeGroup) => ({
|
|
97
|
+
focusableNativeGroup,
|
|
98
|
+
focusableNativeView,
|
|
99
|
+
focusableView,
|
|
100
|
+
focusableGroup,
|
|
101
|
+
}))
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const firstFocusableViewRegistrationFactory = () =>
|
|
108
|
+
focusableViewRegistrationSubject$.pipe(
|
|
109
|
+
take(1), // we care about only first FocusableView registration
|
|
110
|
+
switchMap((focusableView) =>
|
|
111
|
+
// start waiting registration of its parent FocusableGroup
|
|
112
|
+
focusableGroupRegistrationSubject$.pipe(
|
|
113
|
+
filter((focusableGroup) => focusableGroup.id === focusableView.groupId),
|
|
114
|
+
take(1),
|
|
115
|
+
map((focusableGroup) => ({
|
|
116
|
+
focusableView,
|
|
117
|
+
focusableGroup,
|
|
118
|
+
}))
|
|
119
|
+
)
|
|
120
|
+
),
|
|
121
|
+
// start waiting registration for FocusableNativeView and its parent FocusableNativeGroup
|
|
122
|
+
switchMap(({ focusableView, focusableGroup }) =>
|
|
123
|
+
focusableNativeViewRegistration({
|
|
124
|
+
focusableView,
|
|
125
|
+
focusableGroup,
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// registration on RN level(into RN focusManager)
|
|
131
|
+
export const emitRegistered = ({
|
|
132
|
+
id,
|
|
133
|
+
groupId,
|
|
134
|
+
isGroup,
|
|
135
|
+
}: {
|
|
136
|
+
id: Option<FocusableID>;
|
|
137
|
+
groupId: Option<FocusableID>;
|
|
138
|
+
isGroup: boolean;
|
|
139
|
+
}): void => {
|
|
26
140
|
if (isFocusableButton(id)) {
|
|
27
141
|
registeredSubject$.next({ id, registered: true });
|
|
28
142
|
}
|
|
143
|
+
|
|
144
|
+
if (isGroup && id) {
|
|
145
|
+
focusableGroupRegistrationSubject$.next({ id });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!isGroup && id && groupId) {
|
|
149
|
+
focusableViewRegistrationSubject$.next({ id, groupId });
|
|
150
|
+
}
|
|
29
151
|
};
|
|
30
152
|
|
|
153
|
+
// unregistration on RN level(into RN focusManager)
|
|
31
154
|
export const emitUnregistered = (id: Option<FocusableID>): void => {
|
|
32
155
|
if (isFocusableButton(id)) {
|
|
33
156
|
registeredSubject$.next({ id, registered: false });
|
|
34
157
|
}
|
|
35
158
|
};
|
|
159
|
+
|
|
160
|
+
// registration focusableNativeView and focusableNativeGroup
|
|
161
|
+
export const emitNativeRegistered = ({
|
|
162
|
+
id,
|
|
163
|
+
groupId,
|
|
164
|
+
isGroup,
|
|
165
|
+
}: {
|
|
166
|
+
id: Option<FocusableID>;
|
|
167
|
+
groupId: Option<FocusableID>;
|
|
168
|
+
isGroup: boolean;
|
|
169
|
+
}): void => {
|
|
170
|
+
if (!isGroup && id && groupId) {
|
|
171
|
+
focusableNativeViewRegistrationSubject$.next({ id, groupId });
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (isGroup && id && groupId) {
|
|
175
|
+
focusableNativeGroupRegistrationSubject$.next({ id, groupId });
|
|
176
|
+
}
|
|
177
|
+
};
|
|
@@ -10,10 +10,7 @@ import { Platform } from "react-native";
|
|
|
10
10
|
* platformKeys[Platform.OS] should only include keys
|
|
11
11
|
* that are unique to that platform, i.e. Exit: { keyCode: 10182 }
|
|
12
12
|
*/
|
|
13
|
-
export const KEYS = Object.assign(
|
|
14
|
-
platformKeys["web"],
|
|
15
|
-
platformKeys[Platform.OS]
|
|
16
|
-
);
|
|
13
|
+
export const KEYS = Object.assign(platformKeys.web, platformKeys[Platform.OS]);
|
|
17
14
|
|
|
18
15
|
export const ARROW_KEYS = [
|
|
19
16
|
KEYS.ArrowUp,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ReactNative from "react-native";
|
|
2
|
-
import {
|
|
2
|
+
import { useAppData } from "@applicaster/zapp-react-native-redux/hooks";
|
|
3
3
|
|
|
4
4
|
import { isTV, platformSelect } from "../reactUtils";
|
|
5
5
|
import { useIsTablet } from "../reactHooks";
|
|
@@ -184,9 +184,7 @@ export const getScreenOrientation = ({
|
|
|
184
184
|
|
|
185
185
|
export const useGetScreenOrientation = (screenData) => {
|
|
186
186
|
const isTablet = useIsTablet();
|
|
187
|
-
|
|
188
|
-
const { appData } = usePickFromState(["appData"]);
|
|
189
|
-
const isTabletPortrait = appData?.isTabletPortrait;
|
|
187
|
+
const { isTabletPortrait } = useAppData();
|
|
190
188
|
|
|
191
189
|
return getScreenOrientation({
|
|
192
190
|
screenData,
|
|
@@ -79,7 +79,7 @@ export class ClosedCaptioningManager {
|
|
|
79
79
|
private constructor() {
|
|
80
80
|
this.initialize();
|
|
81
81
|
|
|
82
|
-
window
|
|
82
|
+
window.vizioDebug = {
|
|
83
83
|
setCCEnabled: (isCCEnabled: boolean) => {
|
|
84
84
|
this.ccState$.next(isCCEnabled);
|
|
85
85
|
},
|
|
@@ -234,6 +234,7 @@ export class TTSManager {
|
|
|
234
234
|
});
|
|
235
235
|
} catch (error) {
|
|
236
236
|
log_debug("webOS settings service request error", { error });
|
|
237
|
+
// Fallback to false if the service is not available
|
|
237
238
|
this.screenReaderEnabled$.next(false);
|
|
238
239
|
}
|
|
239
240
|
}
|
|
@@ -292,6 +293,7 @@ export class TTSManager {
|
|
|
292
293
|
}
|
|
293
294
|
} catch (error) {
|
|
294
295
|
log_debug("Samsung Voice Guide listener error", { error });
|
|
296
|
+
// Fallback to false if the service is not available
|
|
295
297
|
this.screenReaderEnabled$.next(false);
|
|
296
298
|
}
|
|
297
299
|
}
|
|
@@ -312,31 +314,14 @@ export class TTSManager {
|
|
|
312
314
|
readText(text: string) {
|
|
313
315
|
this.ttsState$.next(true);
|
|
314
316
|
|
|
315
|
-
if (
|
|
316
|
-
|
|
317
|
-
typeof window.tizen !== "undefined" &&
|
|
318
|
-
window.tizen.speech
|
|
319
|
-
) {
|
|
320
|
-
try {
|
|
321
|
-
const successCallback = () => {
|
|
322
|
-
log_debug("Samsung TTS play started successfully");
|
|
323
|
-
// Estimate reading time and set inactive when done
|
|
324
|
-
this.scheduleTTSComplete(text);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
const errorCallback = (error: any) => {
|
|
328
|
-
log_debug("Samsung TTS error", { error: error?.message || error });
|
|
329
|
-
this.ttsState$.next(false);
|
|
330
|
-
};
|
|
317
|
+
if (isSamsungPlatform() && window.speechSynthesis) {
|
|
318
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
331
319
|
|
|
332
|
-
|
|
333
|
-
|
|
320
|
+
window.speechSynthesis.cancel(); // Cancel previous speech before speaking new text
|
|
321
|
+
window.speechSynthesis.speak(utterance);
|
|
334
322
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
log_debug("Samsung TTS speak() error", { error });
|
|
338
|
-
this.ttsState$.next(false);
|
|
339
|
-
}
|
|
323
|
+
// Estimate reading time and set inactive when done
|
|
324
|
+
this.scheduleTTSComplete(text);
|
|
340
325
|
}
|
|
341
326
|
|
|
342
327
|
if (isLgPlatform() && window.webOS?.service) {
|
|
@@ -5,6 +5,7 @@ import { createLogger, utilsLogger } from "../../../logger";
|
|
|
5
5
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
6
6
|
import {
|
|
7
7
|
findPluginByIdentifier,
|
|
8
|
+
loadFeedEntry,
|
|
8
9
|
loadFeedAndPrefetchThumbnailImage,
|
|
9
10
|
parseTimeToSeconds,
|
|
10
11
|
retrieveFeedUrl,
|
|
@@ -26,6 +27,19 @@ type ChapterMarkerOriginal = {
|
|
|
26
27
|
actions: ActionChapter[];
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
export type LiveMetadataEvent = {
|
|
31
|
+
programId: string;
|
|
32
|
+
assetId: string;
|
|
33
|
+
title: string;
|
|
34
|
+
programStartTime: string;
|
|
35
|
+
programEndTime: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type LiveMetadataConfig = {
|
|
39
|
+
updateUrl: string;
|
|
40
|
+
updateInterval: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
29
43
|
export type TitleSummaryEvent = {
|
|
30
44
|
title: string | number;
|
|
31
45
|
summary: string | number;
|
|
@@ -50,11 +64,13 @@ export type PlayNextState = PlayNextConfig & {
|
|
|
50
64
|
export class OverlaysObserver {
|
|
51
65
|
readonly chapterSubject: BehaviorSubject<ChapterMarkerEvent>;
|
|
52
66
|
private playNextSubject: BehaviorSubject<PlayNextState>;
|
|
67
|
+
private liveMetadataSubject: BehaviorSubject<LiveMetadataEvent>;
|
|
53
68
|
private titleSummarySubject: BehaviorSubject<TitleSummaryEvent>;
|
|
54
69
|
private feedUrl: string;
|
|
55
70
|
private reloadData: () => void;
|
|
56
71
|
private updateTitleAndDescription: (data: any) => void;
|
|
57
72
|
private feedDataInterval: any;
|
|
73
|
+
private liveMetadataUpdateInterval: any;
|
|
58
74
|
private releasePlayerObserver?: () => void;
|
|
59
75
|
readonly entry: ZappEntry;
|
|
60
76
|
private chapterMarkerEvents: ChapterMarkerEvent[];
|
|
@@ -66,13 +82,17 @@ export class OverlaysObserver {
|
|
|
66
82
|
this.chapterSubject = new BehaviorSubject(null);
|
|
67
83
|
this.playNextSubject = new BehaviorSubject(null);
|
|
68
84
|
|
|
85
|
+
this.player = player;
|
|
86
|
+
this.entry = player.getEntry();
|
|
87
|
+
|
|
69
88
|
this.titleSummarySubject = new BehaviorSubject<TitleSummaryEvent>({
|
|
70
|
-
title:
|
|
71
|
-
summary:
|
|
89
|
+
title: this.entry?.title || "",
|
|
90
|
+
summary: this.entry?.summary || "",
|
|
72
91
|
});
|
|
73
92
|
|
|
74
|
-
this.
|
|
75
|
-
|
|
93
|
+
this.liveMetadataSubject = new BehaviorSubject<LiveMetadataEvent>(
|
|
94
|
+
this.entry?.extensions?.liveMetadata || null
|
|
95
|
+
);
|
|
76
96
|
|
|
77
97
|
this.chapterMarkerEvents = this.prepareChapterMarkers();
|
|
78
98
|
this.releasePlayerObserver = this.subscribeToPlayerEvents();
|
|
@@ -80,7 +100,9 @@ export class OverlaysObserver {
|
|
|
80
100
|
this.reloadData = () => {};
|
|
81
101
|
this.updateTitleAndDescription = () => {};
|
|
82
102
|
this.feedDataInterval = null;
|
|
103
|
+
this.liveMetadataUpdateInterval = null;
|
|
83
104
|
void this.preparePlayNext();
|
|
105
|
+
void this.prepareLiveMetadata();
|
|
84
106
|
}
|
|
85
107
|
|
|
86
108
|
private setupFeedDataInterval(interval: number) {
|
|
@@ -98,6 +120,13 @@ export class OverlaysObserver {
|
|
|
98
120
|
}
|
|
99
121
|
}
|
|
100
122
|
|
|
123
|
+
public clearLiveMetadataUpdateInterval() {
|
|
124
|
+
if (this.liveMetadataUpdateInterval) {
|
|
125
|
+
clearInterval(this.liveMetadataUpdateInterval);
|
|
126
|
+
this.liveMetadataUpdateInterval = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
101
130
|
public setFeedDataHandlers(
|
|
102
131
|
feedUrl: string,
|
|
103
132
|
reloadData: () => void,
|
|
@@ -197,6 +226,48 @@ export class OverlaysObserver {
|
|
|
197
226
|
}
|
|
198
227
|
};
|
|
199
228
|
|
|
229
|
+
prepareLiveMetadata = async () => {
|
|
230
|
+
if (!this.player?.isLive?.()) {
|
|
231
|
+
log_debug("prepareLiveMetadata: Player is not live. Skipping...");
|
|
232
|
+
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const config: LiveMetadataConfig =
|
|
237
|
+
this.entry?.extensions?.liveMetadataConfig;
|
|
238
|
+
|
|
239
|
+
if (!config?.updateUrl || !config?.updateInterval) {
|
|
240
|
+
log_debug(
|
|
241
|
+
"prepareLiveMetadata: Live metadata configuration is not available. Skipping...",
|
|
242
|
+
{ config }
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const reloadData = async () => {
|
|
249
|
+
try {
|
|
250
|
+
const entry = await loadFeedEntry(config.updateUrl, this.entry);
|
|
251
|
+
|
|
252
|
+
this.onLiveMetadataUpdated(entry?.extensions?.liveMetadata || null);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
log_error("prepareLiveMetadata: Metadata fetching failed", {
|
|
255
|
+
error,
|
|
256
|
+
config,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
log_debug("prepareLiveMetadata: Setting up live metadata observer update", {
|
|
262
|
+
config,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const interval = Number(config?.updateInterval) || 60;
|
|
266
|
+
|
|
267
|
+
this.clearLiveMetadataUpdateInterval();
|
|
268
|
+
this.liveMetadataUpdateInterval = setInterval(reloadData, interval * 1000);
|
|
269
|
+
};
|
|
270
|
+
|
|
200
271
|
// TODO: Hack for video end, will be replaced with playlist prev/next in the future
|
|
201
272
|
getPlayNextEntry = () =>
|
|
202
273
|
!this.isCanceledByUser ? this.playNextConfig?.entry : null;
|
|
@@ -317,9 +388,11 @@ export class OverlaysObserver {
|
|
|
317
388
|
onPlayerClose = () => {
|
|
318
389
|
this.chapterSubject.complete();
|
|
319
390
|
this.playNextSubject.complete();
|
|
391
|
+
this.liveMetadataSubject.complete();
|
|
320
392
|
this.titleSummarySubject.complete();
|
|
321
393
|
this.releasePlayerObserver?.();
|
|
322
394
|
this.clearFeedDataInterval();
|
|
395
|
+
this.clearLiveMetadataUpdateInterval();
|
|
323
396
|
this.releasePlayerObserver = null;
|
|
324
397
|
};
|
|
325
398
|
|
|
@@ -352,4 +425,21 @@ export class OverlaysObserver {
|
|
|
352
425
|
(prev, curr) => prev?.triggerTime === curr?.triggerTime
|
|
353
426
|
)
|
|
354
427
|
);
|
|
428
|
+
|
|
429
|
+
private onLiveMetadataUpdated = (liveMetadataEvent: LiveMetadataEvent) => {
|
|
430
|
+
this.liveMetadataSubject.next(liveMetadataEvent);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
public getLiveMetadataObservable = (): Observable<LiveMetadataEvent> => {
|
|
434
|
+
return this.liveMetadataSubject.pipe(
|
|
435
|
+
distinctUntilChanged(
|
|
436
|
+
(prev, curr) =>
|
|
437
|
+
prev?.programId === curr?.programId && prev?.assetId === curr?.assetId
|
|
438
|
+
)
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
public getLiveMetadataValue = (): LiveMetadataEvent => {
|
|
443
|
+
return this.liveMetadataSubject.value;
|
|
444
|
+
};
|
|
355
445
|
}
|
|
@@ -92,22 +92,26 @@ export const prefetchImage = (playableItem: ZappEntry, config: any = {}) => {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Loads a feed entry from the given feed URL using the provided Zapp entry as context.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} feedUrl - The URL of the feed to load the entry from.
|
|
99
|
+
* @param {ZappEntry} entry - The Zapp entry to use as context for the request.
|
|
100
|
+
* @returns {Promise<ZappEntry>} A promise that resolves to the loaded Zapp entry.
|
|
101
|
+
* @throws {Error} If the feed loading fails or no entry is found in the response.
|
|
102
|
+
*/
|
|
103
|
+
export const loadFeedEntry = async (feedUrl: string, entry: ZappEntry) => {
|
|
100
104
|
const requestBuilder = new RequestBuilder()
|
|
101
105
|
.setEntryContext(entry)
|
|
102
106
|
.setScreenContext({} as ZappRiver)
|
|
103
|
-
.setUrl(
|
|
107
|
+
.setUrl(feedUrl);
|
|
104
108
|
|
|
105
109
|
const responseObject = await requestBuilder.call<ZappEntry>();
|
|
106
110
|
const responseHelper = new PipesClientResponseHelper(responseObject);
|
|
107
111
|
|
|
108
112
|
if (responseHelper.error) {
|
|
109
113
|
log_error(
|
|
110
|
-
`
|
|
114
|
+
`loadFeedEntry: loading failed with error: ${responseHelper.error.message}. Observer will not be executed`,
|
|
111
115
|
{
|
|
112
116
|
response: responseHelper.getLogsData(),
|
|
113
117
|
}
|
|
@@ -116,29 +120,37 @@ export const loadFeedAndPrefetchThumbnailImage = async (
|
|
|
116
120
|
throw responseHelper.error;
|
|
117
121
|
} else {
|
|
118
122
|
log_info(
|
|
119
|
-
`
|
|
123
|
+
`loadFeedEntry: Feed was successfully loaded for url: ${feedUrl}`,
|
|
120
124
|
responseHelper.getLogsData()
|
|
121
125
|
);
|
|
122
126
|
|
|
123
|
-
const
|
|
127
|
+
const entry = responseHelper.responseData?.entry[0];
|
|
124
128
|
|
|
125
|
-
if (!
|
|
126
|
-
|
|
127
|
-
"
|
|
128
|
-
responseHelper.getLogsData()
|
|
129
|
-
);
|
|
129
|
+
if (!entry) {
|
|
130
|
+
const error =
|
|
131
|
+
"loadFeedEntry: Can not retrieve entry, feed was loaded but no entry was found";
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
"Can not retrieve play next entry, feed was loaded but no entry was found"
|
|
133
|
-
);
|
|
134
|
-
}
|
|
133
|
+
log_error(error, responseHelper.getLogsData());
|
|
135
134
|
|
|
136
|
-
|
|
135
|
+
throw new Error(error);
|
|
136
|
+
}
|
|
137
137
|
|
|
138
|
-
return
|
|
138
|
+
return entry;
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
+
export const loadFeedAndPrefetchThumbnailImage = async (
|
|
143
|
+
playNextFeedUrl: string,
|
|
144
|
+
entry: ZappEntry,
|
|
145
|
+
playNextPlugin
|
|
146
|
+
) => {
|
|
147
|
+
const playNextEntry = await loadFeedEntry(playNextFeedUrl, entry);
|
|
148
|
+
|
|
149
|
+
prefetchImage(playNextEntry, playNextPlugin?.configuration);
|
|
150
|
+
|
|
151
|
+
return playNextEntry;
|
|
152
|
+
};
|
|
153
|
+
|
|
142
154
|
export const findPluginByIdentifier = (
|
|
143
155
|
identifier: string,
|
|
144
156
|
plugins: ZappPlugin[]
|
|
@@ -15,6 +15,22 @@ const logger = createLogger({
|
|
|
15
15
|
|
|
16
16
|
const { log_warning } = logger;
|
|
17
17
|
|
|
18
|
+
interface PlayerMethods {
|
|
19
|
+
seeking?: (position: number) => void;
|
|
20
|
+
forward?: (deltaTime: number) => void;
|
|
21
|
+
rewind?: (deltaTime: number) => void;
|
|
22
|
+
startSleepTimer?: (sleepTimestamp: number) => void;
|
|
23
|
+
selectTrack?: (
|
|
24
|
+
selected: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
25
|
+
) => void;
|
|
26
|
+
setPlaybackRate?: (rate: number) => void;
|
|
27
|
+
appStateChange?: (appState: string, previousAppState: string) => void;
|
|
28
|
+
closeNativePlayer?: () => void;
|
|
29
|
+
togglePlayPause?: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type PlayerComponent = ReactComponent<PlayerRefProps> & PlayerMethods;
|
|
33
|
+
|
|
18
34
|
type PlayerPlugnId = "QuickBrickPlayerPlugin" | "KalturaPlayerPlugin";
|
|
19
35
|
|
|
20
36
|
type Props = {
|
|
@@ -62,7 +78,7 @@ export class PlayerNative extends Player {
|
|
|
62
78
|
return this.playerState.contentPosition;
|
|
63
79
|
};
|
|
64
80
|
|
|
65
|
-
currentPlayerComponent = ():
|
|
81
|
+
currentPlayerComponent = (): PlayerComponent | null =>
|
|
66
82
|
this.playerComponent?.current;
|
|
67
83
|
|
|
68
84
|
getState = () => this.playerState;
|
|
@@ -121,7 +137,7 @@ export class PlayerNative extends Player {
|
|
|
121
137
|
|
|
122
138
|
this.playerState.seekPosition = newPosition;
|
|
123
139
|
|
|
124
|
-
this.currentPlayerComponent()?.
|
|
140
|
+
this.currentPlayerComponent()?.seeking?.(this.playerState.seekPosition);
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
this.logState(PlayerModuleFuncNames.seekTo, { position });
|
|
@@ -135,7 +151,7 @@ export class PlayerNative extends Player {
|
|
|
135
151
|
if (!this.invokeNativeFunction(PlayerModuleFuncNames.forward, deltaTime)) {
|
|
136
152
|
// Kaltura does not have yet this implementation, use legacy code
|
|
137
153
|
|
|
138
|
-
this.currentPlayerComponent()?.
|
|
154
|
+
this.currentPlayerComponent()?.forward?.(deltaTime);
|
|
139
155
|
}
|
|
140
156
|
|
|
141
157
|
this.notifyPlayHeadPositionUpdate();
|
|
@@ -151,7 +167,7 @@ export class PlayerNative extends Player {
|
|
|
151
167
|
if (!this.invokeNativeFunction(PlayerModuleFuncNames.rewind, deltaTime)) {
|
|
152
168
|
// Kaltura does not have yet this implementation, use legacy code
|
|
153
169
|
|
|
154
|
-
this.currentPlayerComponent()?.
|
|
170
|
+
this.currentPlayerComponent()?.rewind?.(deltaTime);
|
|
155
171
|
}
|
|
156
172
|
|
|
157
173
|
this.notifyPlayHeadPositionUpdate();
|
|
@@ -178,7 +194,7 @@ export class PlayerNative extends Player {
|
|
|
178
194
|
sleepTimestamp
|
|
179
195
|
)
|
|
180
196
|
) {
|
|
181
|
-
this.currentPlayerComponent()?.
|
|
197
|
+
this.currentPlayerComponent()?.startSleepTimer?.(sleepTimestamp);
|
|
182
198
|
}
|
|
183
199
|
};
|
|
184
200
|
|
|
@@ -195,11 +211,11 @@ export class PlayerNative extends Player {
|
|
|
195
211
|
selectTrack = (
|
|
196
212
|
selected: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
|
|
197
213
|
) => {
|
|
198
|
-
this.currentPlayerComponent()?.
|
|
214
|
+
this.currentPlayerComponent()?.selectTrack?.(selected);
|
|
199
215
|
};
|
|
200
216
|
|
|
201
217
|
setPlaybackRate = (rate: number) => {
|
|
202
|
-
this.currentPlayerComponent()?.
|
|
218
|
+
this.currentPlayerComponent()?.setPlaybackRate?.(rate);
|
|
203
219
|
};
|
|
204
220
|
|
|
205
221
|
getPluginConfiguration = () => {
|
|
@@ -209,19 +225,16 @@ export class PlayerNative extends Player {
|
|
|
209
225
|
getProps = () => (this.currentPlayerComponent() as any)?.props;
|
|
210
226
|
|
|
211
227
|
appStateChange = (appState, previousAppState) => {
|
|
212
|
-
this.currentPlayerComponent()?.
|
|
213
|
-
appState,
|
|
214
|
-
previousAppState
|
|
215
|
-
);
|
|
228
|
+
this.currentPlayerComponent()?.appStateChange?.(appState, previousAppState);
|
|
216
229
|
};
|
|
217
230
|
|
|
218
231
|
closeNativePlayer = () => {
|
|
219
232
|
// TODO: Delete does not work
|
|
220
|
-
this.currentPlayerComponent()?.
|
|
233
|
+
this.currentPlayerComponent()?.closeNativePlayer?.();
|
|
221
234
|
};
|
|
222
235
|
|
|
223
236
|
togglePlayPause = () => {
|
|
224
|
-
this.currentPlayerComponent()?.
|
|
237
|
+
this.currentPlayerComponent()?.togglePlayPause?.();
|
|
225
238
|
};
|
|
226
239
|
|
|
227
240
|
onVideoLoad = (event) => {
|
|
@@ -289,19 +302,19 @@ export class PlayerNative extends Player {
|
|
|
289
302
|
isFullScreenSupported = (): boolean => {
|
|
290
303
|
const config = this.getConfig();
|
|
291
304
|
|
|
292
|
-
const disableFullScreen = config?.
|
|
305
|
+
const disableFullScreen = config?.disable_fullscreen;
|
|
293
306
|
|
|
294
307
|
if (disableFullScreen) {
|
|
295
308
|
return false;
|
|
296
309
|
}
|
|
297
310
|
|
|
298
|
-
const isFullScreenAudioPlayer = config?.
|
|
311
|
+
const isFullScreenAudioPlayer = config?.full_screen_audio_player;
|
|
299
312
|
|
|
300
313
|
return !(isFullScreenAudioPlayer && this.isAudioItem());
|
|
301
314
|
};
|
|
302
315
|
|
|
303
316
|
supportsNativeControls = (): boolean =>
|
|
304
|
-
toBooleanWithDefaultFalse(this.getConfig()?.
|
|
317
|
+
toBooleanWithDefaultFalse(this.getConfig()?.supports_native_controls);
|
|
305
318
|
|
|
306
319
|
supportNativeCast = (): boolean =>
|
|
307
320
|
toBooleanWithDefaultFalse(
|