@applicaster/zapp-react-native-utils 15.0.0-alpha.8621453569 → 15.0.0-alpha.8680244503
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/const.ts +4 -0
- package/appUtils/accessibilityManager/hooks.ts +8 -24
- package/appUtils/keyCodes/keys/keys.web.ts +1 -4
- package/appUtils/orientationHelper.ts +2 -4
- package/appUtils/platform/platformUtils.ts +51 -35
- 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/manifestUtils/defaultManifestConfigurations/player.js +75 -1
- package/manifestUtils/keys.js +21 -0
- 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 +8 -3
- 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/useEntryScreenId.ts +2 -2
- 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 +7 -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 +3 -0
- package/utils/selectors.ts +46 -0
- package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +15 -6
|
@@ -23,12 +23,9 @@ import {
|
|
|
23
23
|
EntryResolver,
|
|
24
24
|
resolveObjectValues,
|
|
25
25
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
26
|
-
import { useNavigation } from "../reactHooks";
|
|
26
|
+
import { useNavigation, useRivers } from "../reactHooks";
|
|
27
27
|
|
|
28
|
-
import {
|
|
29
|
-
useContentTypes,
|
|
30
|
-
usePickFromState,
|
|
31
|
-
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
28
|
+
import { useContentTypes } from "@applicaster/zapp-react-native-redux/hooks";
|
|
32
29
|
import { useSubscriberFor } from "../reactHooks/useSubscriberFor";
|
|
33
30
|
import { APP_EVENTS } from "../appUtils/events";
|
|
34
31
|
import {
|
|
@@ -278,7 +275,7 @@ export function withActionExecutor(Component) {
|
|
|
278
275
|
|
|
279
276
|
return function ActionExecutorComponent(props: Props) {
|
|
280
277
|
const navigator = useNavigation();
|
|
281
|
-
const
|
|
278
|
+
const rivers = useRivers();
|
|
282
279
|
const contentTypes = useContentTypes();
|
|
283
280
|
|
|
284
281
|
const handlers = useMemo(() => {
|
|
@@ -27,7 +27,7 @@ function makeMultiSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
const behavior = {
|
|
30
|
-
...feed.extensions?.
|
|
30
|
+
...feed.extensions?.behavior,
|
|
31
31
|
select_mode: "multi",
|
|
32
32
|
current_selection: `@{${scope}/${key}}`,
|
|
33
33
|
};
|
|
@@ -75,7 +75,7 @@ function makeSingleSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
const behavior = {
|
|
78
|
-
...feed.extensions?.
|
|
78
|
+
...feed.extensions?.behavior,
|
|
79
79
|
select_mode: "single",
|
|
80
80
|
current_selection: `@{${scope}/${key}}`,
|
|
81
81
|
};
|
|
@@ -141,11 +141,11 @@ function makeSingleSelect(feed: ZappFeed, key, decoratedFeed) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export const decorateFeed = (feed: ZappFeed) => {
|
|
144
|
-
if (!(feed.extensions?.
|
|
144
|
+
if (!(feed.extensions?.role === "preference_editor")) {
|
|
145
145
|
return feed;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const key = feed.extensions?.
|
|
148
|
+
const key = feed.extensions?.preference_editor_options?.key;
|
|
149
149
|
|
|
150
150
|
if (!key) {
|
|
151
151
|
log_error(
|
|
@@ -160,8 +160,8 @@ export const decorateFeed = (feed: ZappFeed) => {
|
|
|
160
160
|
const decoratedFeed = R.clone(feed);
|
|
161
161
|
|
|
162
162
|
const isSingleSelect =
|
|
163
|
-
(feed.extensions?.
|
|
164
|
-
feed.extensions?.
|
|
163
|
+
(feed.extensions?.preference_editor_options?.select_mode ||
|
|
164
|
+
feed.extensions?.behavior?.select_mode) === "single";
|
|
165
165
|
|
|
166
166
|
if (isSingleSelect) {
|
|
167
167
|
return makeSingleSelect(feed, key, decoratedFeed);
|
package/adsUtils/index.ts
CHANGED
|
@@ -33,10 +33,10 @@ function convertOffset(offset: any): string {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function createAdBreak(ad: AdMap): string {
|
|
36
|
-
const offset = ad
|
|
36
|
+
const offset = ad.offset;
|
|
37
37
|
const id = offset.toString();
|
|
38
38
|
const timestamp = convertOffset(offset);
|
|
39
|
-
const url = ad
|
|
39
|
+
const url = ad.ad_url.toString().trim();
|
|
40
40
|
|
|
41
41
|
return `
|
|
42
42
|
<vmap:AdBreak timeOffset="${timestamp}" breakType="linear" breakId="break-${id}">
|
package/analyticsUtils/README.md
CHANGED
|
@@ -388,7 +388,7 @@ export function AnalyticsProvider(props: ComponentWithChildrenProps) {
|
|
|
388
388
|
|
|
389
389
|
```ts
|
|
390
390
|
export function useAnalytics(props: any): any {
|
|
391
|
-
const
|
|
391
|
+
const appData = useAppData();
|
|
392
392
|
const getAnalyticsFunctions = React.useContext(AnalyticsContext);
|
|
393
393
|
|
|
394
394
|
const analyticsFunctions = React.useMemo(
|
|
@@ -230,7 +230,7 @@ export function HooksManager({
|
|
|
230
230
|
function completeHook(hookPlugin, payload, callback) {
|
|
231
231
|
logHookEvent(
|
|
232
232
|
hooksManagerLogger.info,
|
|
233
|
-
`completeHook: hook sequence completed successfully: ${hookPlugin
|
|
233
|
+
`completeHook: hook sequence completed successfully: ${hookPlugin.identifier}`,
|
|
234
234
|
{
|
|
235
235
|
payload,
|
|
236
236
|
hook: hookPlugin,
|
|
@@ -276,7 +276,7 @@ export function HooksManager({
|
|
|
276
276
|
if (hookPlugin.isCancelled()) {
|
|
277
277
|
logHookEvent(
|
|
278
278
|
hooksManagerLogger.info,
|
|
279
|
-
`hookCallback: hook was cancelled: ${hookPlugin
|
|
279
|
+
`hookCallback: hook was cancelled: ${hookPlugin.identifier}`,
|
|
280
280
|
{}
|
|
281
281
|
);
|
|
282
282
|
|
|
@@ -305,7 +305,7 @@ export function HooksManager({
|
|
|
305
305
|
if (!success) {
|
|
306
306
|
logHookEvent(
|
|
307
307
|
hooksManagerLogger.info,
|
|
308
|
-
`hookCallback: hook was cancelled: ${hookPlugin
|
|
308
|
+
`hookCallback: hook was cancelled: ${hookPlugin.identifier}`,
|
|
309
309
|
{
|
|
310
310
|
payload,
|
|
311
311
|
hook: hookPlugin,
|
|
@@ -334,7 +334,7 @@ export function HooksManager({
|
|
|
334
334
|
if (isHookInHomescreen && isHookFlowBlocker && cancelled) {
|
|
335
335
|
logHookEvent(
|
|
336
336
|
hooksManagerLogger.info,
|
|
337
|
-
`hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin
|
|
337
|
+
`hookCallback: send app to background, cancelled flow blocker hook ${hookPlugin.identifier} on home screen`,
|
|
338
338
|
{
|
|
339
339
|
payload,
|
|
340
340
|
hook: hookPlugin,
|
|
@@ -349,7 +349,7 @@ export function HooksManager({
|
|
|
349
349
|
} else {
|
|
350
350
|
logHookEvent(
|
|
351
351
|
hooksManagerLogger.info,
|
|
352
|
-
`hookCallback: hook successfully finished: ${hookPlugin
|
|
352
|
+
`hookCallback: hook successfully finished: ${hookPlugin.identifier}`,
|
|
353
353
|
{
|
|
354
354
|
payload,
|
|
355
355
|
hook: hookPlugin,
|
|
@@ -359,7 +359,7 @@ export function HooksManager({
|
|
|
359
359
|
if (!callback) {
|
|
360
360
|
logHookEvent(
|
|
361
361
|
hooksManagerLogger.warn,
|
|
362
|
-
`hookCallback: ${hookPlugin
|
|
362
|
+
`hookCallback: ${hookPlugin.identifier} is missing \`callback\`, using hookCallback(default one)`,
|
|
363
363
|
{
|
|
364
364
|
hookPlugin,
|
|
365
365
|
}
|
|
@@ -401,7 +401,7 @@ export function HooksManager({
|
|
|
401
401
|
|
|
402
402
|
logHookEvent(
|
|
403
403
|
hooksManagerLogger.info,
|
|
404
|
-
`presentScreenHook: Presenting screen hook: ${hookPlugin
|
|
404
|
+
`presentScreenHook: Presenting screen hook: ${hookPlugin.identifier}`,
|
|
405
405
|
{
|
|
406
406
|
hook: hookPlugin,
|
|
407
407
|
payload,
|
|
@@ -421,7 +421,7 @@ export function HooksManager({
|
|
|
421
421
|
hooksManager.executeHook = function (hookPlugin, payload, callback) {
|
|
422
422
|
logHookEvent(
|
|
423
423
|
hooksManagerLogger.info,
|
|
424
|
-
`executeHook: ${hookPlugin
|
|
424
|
+
`executeHook: ${hookPlugin.identifier}`,
|
|
425
425
|
{
|
|
426
426
|
hook: hookPlugin,
|
|
427
427
|
payload,
|
|
@@ -433,7 +433,7 @@ export function HooksManager({
|
|
|
433
433
|
} catch (error) {
|
|
434
434
|
logHookEvent(
|
|
435
435
|
hooksManagerLogger.error,
|
|
436
|
-
`executeHook: error executing hook: ${hookPlugin
|
|
436
|
+
`executeHook: error executing hook: ${hookPlugin.identifier} error: ${error.message}`,
|
|
437
437
|
{
|
|
438
438
|
hook: hookPlugin,
|
|
439
439
|
payload,
|
|
@@ -460,7 +460,7 @@ export function HooksManager({
|
|
|
460
460
|
try {
|
|
461
461
|
logHookEvent(
|
|
462
462
|
hooksManagerLogger.info,
|
|
463
|
-
`runInBackground: Executing hook: ${hookPlugin
|
|
463
|
+
`runInBackground: Executing hook: ${hookPlugin.identifier}`,
|
|
464
464
|
{
|
|
465
465
|
hook: hookPlugin,
|
|
466
466
|
payload,
|
|
@@ -31,6 +31,10 @@ export const BUTTON_ACCESSIBILITY_KEYS = {
|
|
|
31
31
|
hint: "accessibility_close_mini_hint",
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
+
back_to_live: {
|
|
35
|
+
label: "back_to_live_label",
|
|
36
|
+
hint: "",
|
|
37
|
+
},
|
|
34
38
|
maximize: {
|
|
35
39
|
label: "accessibility_maximize_label",
|
|
36
40
|
hint: "accessibility_maximize_hint",
|
|
@@ -23,19 +23,6 @@ export const useAccessibilityManager = (
|
|
|
23
23
|
}
|
|
24
24
|
}, [pluginConfiguration, accessibilityManager]);
|
|
25
25
|
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const subscription = accessibilityManager.getStateAsObservable().subscribe({
|
|
28
|
-
next: () => {
|
|
29
|
-
// TODO: handle accessibility states
|
|
30
|
-
// screenReaderEnabled: false
|
|
31
|
-
// reduceMotionEnabled: false
|
|
32
|
-
// boldTextEnabled: false
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return () => subscription.unsubscribe();
|
|
37
|
-
}, [accessibilityManager]);
|
|
38
|
-
|
|
39
26
|
return accessibilityManager;
|
|
40
27
|
};
|
|
41
28
|
|
|
@@ -73,25 +60,22 @@ export const useAnnouncementActive = (
|
|
|
73
60
|
return isActive;
|
|
74
61
|
};
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* Returns a boolean that updates reactively when screen reader is enabled/disabled
|
|
79
|
-
* @returns boolean - true if screen reader is enabled, false otherwise
|
|
80
|
-
*/
|
|
81
|
-
export const useScreenReaderEnabled = (
|
|
82
|
-
accessibilityManager: AccessibilityManager
|
|
63
|
+
export const useAccessibilityState = (
|
|
64
|
+
pluginConfiguration: Record<string, any> = {}
|
|
83
65
|
) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
66
|
+
const accessibilityManager = useAccessibilityManager(pluginConfiguration);
|
|
67
|
+
|
|
68
|
+
const [state, setState] = useState<AccessibilityState>(
|
|
69
|
+
accessibilityManager.getState()
|
|
86
70
|
);
|
|
87
71
|
|
|
88
72
|
useEffect(() => {
|
|
89
73
|
const subscription = accessibilityManager
|
|
90
74
|
.getStateAsObservable()
|
|
91
|
-
.subscribe(
|
|
75
|
+
.subscribe(setState);
|
|
92
76
|
|
|
93
77
|
return () => subscription.unsubscribe();
|
|
94
78
|
}, [accessibilityManager]);
|
|
95
79
|
|
|
96
|
-
return
|
|
80
|
+
return state;
|
|
97
81
|
};
|
|
@@ -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
|
},
|
|
@@ -209,10 +209,11 @@ export class TTSManager {
|
|
|
209
209
|
|
|
210
210
|
if (isLgPlatform() && window.webOS?.service) {
|
|
211
211
|
try {
|
|
212
|
+
// https://webostv.developer.lge.com/develop/references/settings-service
|
|
212
213
|
window.webOS.service.request("luna://com.webos.settingsservice", {
|
|
213
214
|
method: "getSystemSettings",
|
|
214
215
|
parameters: {
|
|
215
|
-
category: "
|
|
216
|
+
category: "option",
|
|
216
217
|
keys: ["audioGuidance"],
|
|
217
218
|
subscribe: true, // Request a subscription to changes
|
|
218
219
|
},
|
|
@@ -233,34 +234,66 @@ export class TTSManager {
|
|
|
233
234
|
});
|
|
234
235
|
} catch (error) {
|
|
235
236
|
log_debug("webOS settings service request error", { error });
|
|
237
|
+
// Fallback to false if the service is not available
|
|
236
238
|
this.screenReaderEnabled$.next(false);
|
|
237
239
|
}
|
|
238
240
|
}
|
|
239
241
|
|
|
240
|
-
if (isSamsungPlatform() && typeof window.
|
|
242
|
+
if (isSamsungPlatform() && typeof window.webapis !== "undefined") {
|
|
241
243
|
try {
|
|
242
244
|
if (
|
|
243
|
-
window.
|
|
244
|
-
typeof window.
|
|
245
|
-
|
|
245
|
+
window.webapis?.tvinfo &&
|
|
246
|
+
typeof window.webapis.tvinfo.getMenuValue === "function" &&
|
|
247
|
+
typeof window.webapis.tvinfo.addCaptionChangeListener === "function"
|
|
246
248
|
) {
|
|
249
|
+
// Get initial Voice Guide status
|
|
250
|
+
const initialStatus = window.webapis.tvinfo.getMenuValue(
|
|
251
|
+
window.webapis.tvinfo.TvInfoMenuKey.VOICE_GUIDE_KEY
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
const isEnabled =
|
|
255
|
+
initialStatus === window.webapis.tvinfo.TvInfoMenuValue.ON;
|
|
256
|
+
|
|
257
|
+
log_debug("Samsung Voice Guide initial status", {
|
|
258
|
+
isEnabled,
|
|
259
|
+
initialStatus,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
this.screenReaderEnabled$.next(isEnabled);
|
|
263
|
+
|
|
264
|
+
// Listen for Voice Guide status changes
|
|
265
|
+
const onChange = () => {
|
|
266
|
+
const currentStatus = window.webapis.tvinfo.getMenuValue(
|
|
267
|
+
window.webapis.tvinfo.TvInfoMenuKey.VOICE_GUIDE_KEY
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const enabled =
|
|
271
|
+
currentStatus === window.webapis.tvinfo.TvInfoMenuValue.ON;
|
|
272
|
+
|
|
273
|
+
log_debug("Samsung Voice Guide status changed", {
|
|
274
|
+
enabled,
|
|
275
|
+
currentStatus,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
this.screenReaderEnabled$.next(enabled);
|
|
279
|
+
};
|
|
280
|
+
|
|
247
281
|
this.samsungListenerId =
|
|
248
|
-
window.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
this.screenReaderEnabled$.next(!!enabled);
|
|
252
|
-
}
|
|
282
|
+
window.webapis.tvinfo.addCaptionChangeListener(
|
|
283
|
+
window.webapis.tvinfo.TvInfoMenuKey.VOICE_GUIDE_KEY,
|
|
284
|
+
onChange
|
|
253
285
|
);
|
|
254
286
|
|
|
255
287
|
log_debug("Samsung Voice Guide listener registered", {
|
|
256
288
|
listenerId: this.samsungListenerId,
|
|
257
289
|
});
|
|
258
290
|
} else {
|
|
259
|
-
log_debug("Samsung
|
|
291
|
+
log_debug("Samsung TvInfo API not available");
|
|
260
292
|
this.screenReaderEnabled$.next(false);
|
|
261
293
|
}
|
|
262
294
|
} catch (error) {
|
|
263
295
|
log_debug("Samsung Voice Guide listener error", { error });
|
|
296
|
+
// Fallback to false if the service is not available
|
|
264
297
|
this.screenReaderEnabled$.next(false);
|
|
265
298
|
}
|
|
266
299
|
}
|
|
@@ -281,31 +314,14 @@ export class TTSManager {
|
|
|
281
314
|
readText(text: string) {
|
|
282
315
|
this.ttsState$.next(true);
|
|
283
316
|
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
typeof window.tizen !== "undefined" &&
|
|
287
|
-
window.tizen.speech
|
|
288
|
-
) {
|
|
289
|
-
try {
|
|
290
|
-
const successCallback = () => {
|
|
291
|
-
log_debug("Samsung TTS play started successfully");
|
|
292
|
-
// Estimate reading time and set inactive when done
|
|
293
|
-
this.scheduleTTSComplete(text);
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
const errorCallback = (error: any) => {
|
|
297
|
-
log_debug("Samsung TTS error", { error: error?.message || error });
|
|
298
|
-
this.ttsState$.next(false);
|
|
299
|
-
};
|
|
317
|
+
if (isSamsungPlatform() && window.speechSynthesis) {
|
|
318
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
300
319
|
|
|
301
|
-
|
|
302
|
-
|
|
320
|
+
window.speechSynthesis.cancel(); // Cancel previous speech before speaking new text
|
|
321
|
+
window.speechSynthesis.speak(utterance);
|
|
303
322
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
log_debug("Samsung TTS speak() error", { error });
|
|
307
|
-
this.ttsState$.next(false);
|
|
308
|
-
}
|
|
323
|
+
// Estimate reading time and set inactive when done
|
|
324
|
+
this.scheduleTTSComplete(text);
|
|
309
325
|
}
|
|
310
326
|
|
|
311
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[]
|