@applicaster/zapp-react-native-utils 15.0.0-alpha.8621453569 → 15.0.0-alpha.9331298916
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/appUtils/accessibilityManager/const.ts +4 -0
- package/appUtils/accessibilityManager/hooks.ts +0 -23
- package/appUtils/accessibilityManager/index.ts +1 -28
- package/appUtils/accessibilityManager/utils.ts +5 -36
- package/appUtils/platform/platformUtils.ts +21 -104
- 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/usePlayerState.tsx +14 -2
- package/cellUtils/index.ts +1 -40
- package/manifestUtils/defaultManifestConfigurations/player.js +52 -1
- package/manifestUtils/keys.js +21 -0
- package/manifestUtils/sharedConfiguration/screenPicker/utils.js +1 -0
- package/package.json +2 -2
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
|
@@ -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",
|
|
@@ -72,26 +72,3 @@ export const useAnnouncementActive = (
|
|
|
72
72
|
|
|
73
73
|
return isActive;
|
|
74
74
|
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Hook to get the current screen reader enabled state
|
|
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
|
|
83
|
-
) => {
|
|
84
|
-
const [isEnabled, setIsEnabled] = useState(
|
|
85
|
-
accessibilityManager.getState().screenReaderEnabled
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
const subscription = accessibilityManager
|
|
90
|
-
.getStateAsObservable()
|
|
91
|
-
.subscribe((state) => setIsEnabled(state.screenReaderEnabled));
|
|
92
|
-
|
|
93
|
-
return () => subscription.unsubscribe();
|
|
94
|
-
}, [accessibilityManager]);
|
|
95
|
-
|
|
96
|
-
return isEnabled;
|
|
97
|
-
};
|
|
@@ -36,20 +36,7 @@ export class AccessibilityManager {
|
|
|
36
36
|
false
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
private constructor() {
|
|
40
|
-
this.ttsManager
|
|
41
|
-
.getScreenReaderEnabledAsObservable()
|
|
42
|
-
.subscribe((enabled) => {
|
|
43
|
-
const state = this.state$.getValue();
|
|
44
|
-
|
|
45
|
-
if (state.screenReaderEnabled !== enabled) {
|
|
46
|
-
this.state$.next({
|
|
47
|
-
...state,
|
|
48
|
-
screenReaderEnabled: enabled,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
39
|
+
private constructor() {}
|
|
53
40
|
|
|
54
41
|
public static getInstance(): AccessibilityManager {
|
|
55
42
|
if (!AccessibilityManager._instance) {
|
|
@@ -105,15 +92,8 @@ export class AccessibilityManager {
|
|
|
105
92
|
/**
|
|
106
93
|
* Adds a heading to the queue, headings will be read before the next text
|
|
107
94
|
* Each heading will be read once and removed from the queue
|
|
108
|
-
* Does nothing if screen reader is not enabled
|
|
109
95
|
*/
|
|
110
96
|
public addHeading(heading: string) {
|
|
111
|
-
const state = this.state$.getValue();
|
|
112
|
-
|
|
113
|
-
if (!state.screenReaderEnabled) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
97
|
if (!this.pendingFocusId) {
|
|
118
98
|
this.pendingFocusId = Date.now().toString();
|
|
119
99
|
}
|
|
@@ -128,7 +108,6 @@ export class AccessibilityManager {
|
|
|
128
108
|
*
|
|
129
109
|
* Implements a delay mechanism to reduce noise during rapid navigation.
|
|
130
110
|
* Only the most recent announcement will be read after the delay period.
|
|
131
|
-
* Does nothing if screen reader is not enabled
|
|
132
111
|
*/
|
|
133
112
|
public readText({
|
|
134
113
|
text,
|
|
@@ -137,12 +116,6 @@ export class AccessibilityManager {
|
|
|
137
116
|
text: string;
|
|
138
117
|
keyOfLocalizedText?: string;
|
|
139
118
|
}) {
|
|
140
|
-
const state = this.state$.getValue();
|
|
141
|
-
|
|
142
|
-
if (!state.screenReaderEnabled) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
119
|
let textToRead = text;
|
|
147
120
|
|
|
148
121
|
if (keyOfLocalizedText) {
|
|
@@ -12,44 +12,13 @@ export function calculateReadingTime(
|
|
|
12
12
|
minimumPause: number = 500,
|
|
13
13
|
announcementDelay: number = 700
|
|
14
14
|
): number {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
// Count words (split on whitespace and punctuation, keep alnum boundaries)
|
|
18
|
-
const words = trimmed
|
|
15
|
+
const words = text
|
|
16
|
+
.trim()
|
|
19
17
|
.split(/(?<=\d)(?=[a-zA-Z])|(?<=[a-zA-Z])(?=\d)|[^\w\s]+|\s+/)
|
|
20
18
|
.filter(Boolean).length;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const totalSpaces = spaceMatches.reduce(
|
|
26
|
-
(sum: number, match: string) => sum + match.length,
|
|
27
|
-
0
|
|
20
|
+
return (
|
|
21
|
+
Math.max(minimumPause, (words / wordsPerMinute) * 60 * 1000) +
|
|
22
|
+
announcementDelay
|
|
28
23
|
);
|
|
29
|
-
|
|
30
|
-
const extraSpaces = Math.max(0, totalSpaces - (words - 1)); // words-1 is normal spacing
|
|
31
|
-
|
|
32
|
-
// Heuristic: punctuation increases TTS duration beyond word-based WPM.
|
|
33
|
-
// Commas typically introduce short pauses, sentence terminators longer ones.
|
|
34
|
-
const commaCount = (trimmed.match(/,/g) || []).length;
|
|
35
|
-
const semicolonCount = (trimmed.match(/;/g) || []).length;
|
|
36
|
-
const colonCount = (trimmed.match(/:/g) || []).length;
|
|
37
|
-
const dashCount = (trimmed.match(/\u2013|\u2014|-/g) || []).length; // – — -
|
|
38
|
-
const sentenceEndCount = (trimmed.match(/[.!?](?!\d)/g) || []).length;
|
|
39
|
-
|
|
40
|
-
const commaPauseMs = 220; // short prosody pause for ","
|
|
41
|
-
const midPauseMs = 260; // for ";", ":", dashes
|
|
42
|
-
const sentenceEndPauseMs = 420; // for ".", "!", "?"
|
|
43
|
-
const extraSpacePauseMs = 50; // per extra space beyond normal spacing
|
|
44
|
-
|
|
45
|
-
const punctuationPause =
|
|
46
|
-
commaCount * commaPauseMs +
|
|
47
|
-
(semicolonCount + colonCount + dashCount) * midPauseMs +
|
|
48
|
-
sentenceEndCount * sentenceEndPauseMs +
|
|
49
|
-
extraSpaces * extraSpacePauseMs;
|
|
50
|
-
|
|
51
|
-
const baseByWordsMs = (words / wordsPerMinute) * 60 * 1000;
|
|
52
|
-
const estimatedMs = Math.max(minimumPause, baseByWordsMs + punctuationPause);
|
|
53
|
-
|
|
54
|
-
return estimatedMs + announcementDelay;
|
|
55
24
|
}
|
|
@@ -170,9 +170,7 @@ export const getClosedCaptionState = () => {
|
|
|
170
170
|
*/
|
|
171
171
|
export class TTSManager {
|
|
172
172
|
private ttsState$ = new BehaviorSubject<boolean>(false);
|
|
173
|
-
private screenReaderEnabled$ = new BehaviorSubject<boolean>(false);
|
|
174
173
|
private static ttsManagerInstance: TTSManager;
|
|
175
|
-
private samsungListenerId: number | null = null;
|
|
176
174
|
|
|
177
175
|
private constructor() {
|
|
178
176
|
this.initialize();
|
|
@@ -187,83 +185,23 @@ export class TTSManager {
|
|
|
187
185
|
}
|
|
188
186
|
|
|
189
187
|
async initialize() {
|
|
190
|
-
if (isVizioPlatform())
|
|
191
|
-
document.addEventListener(
|
|
192
|
-
"VIZIO_TTS_ENABLED",
|
|
193
|
-
() => {
|
|
194
|
-
log_debug("Vizio screen reader enabled");
|
|
195
|
-
this.screenReaderEnabled$.next(true);
|
|
196
|
-
},
|
|
197
|
-
false
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
document.addEventListener(
|
|
201
|
-
"VIZIO_TTS_DISABLED",
|
|
202
|
-
() => {
|
|
203
|
-
log_debug("Vizio screen reader disabled");
|
|
204
|
-
this.screenReaderEnabled$.next(false);
|
|
205
|
-
},
|
|
206
|
-
false
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (isLgPlatform() && window.webOS?.service) {
|
|
211
|
-
try {
|
|
212
|
-
window.webOS.service.request("luna://com.webos.settingsservice", {
|
|
213
|
-
method: "getSystemSettings",
|
|
214
|
-
parameters: {
|
|
215
|
-
category: "accessibility",
|
|
216
|
-
keys: ["audioGuidance"],
|
|
217
|
-
subscribe: true, // Request a subscription to changes
|
|
218
|
-
},
|
|
219
|
-
onSuccess: (response: any) => {
|
|
220
|
-
const isEnabled = response?.settings?.audioGuidance === "on";
|
|
188
|
+
if (!isVizioPlatform()) return;
|
|
221
189
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
onFailure: (error: any) => {
|
|
230
|
-
log_debug("webOS settings subscription failed", { error });
|
|
231
|
-
this.screenReaderEnabled$.next(false);
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
} catch (error) {
|
|
235
|
-
log_debug("webOS settings service request error", { error });
|
|
236
|
-
this.screenReaderEnabled$.next(false);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
190
|
+
document.addEventListener(
|
|
191
|
+
"VIZIO_TTS_ENABLED",
|
|
192
|
+
() => {
|
|
193
|
+
this.ttsState$.next(true);
|
|
194
|
+
},
|
|
195
|
+
false
|
|
196
|
+
);
|
|
239
197
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this.samsungListenerId =
|
|
248
|
-
window.tizen.accessibility.addVoiceGuideStatusChangeListener(
|
|
249
|
-
(enabled: boolean) => {
|
|
250
|
-
log_debug("Samsung Voice Guide status changed", { enabled });
|
|
251
|
-
this.screenReaderEnabled$.next(!!enabled);
|
|
252
|
-
}
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
log_debug("Samsung Voice Guide listener registered", {
|
|
256
|
-
listenerId: this.samsungListenerId,
|
|
257
|
-
});
|
|
258
|
-
} else {
|
|
259
|
-
log_debug("Samsung accessibility API not available");
|
|
260
|
-
this.screenReaderEnabled$.next(false);
|
|
261
|
-
}
|
|
262
|
-
} catch (error) {
|
|
263
|
-
log_debug("Samsung Voice Guide listener error", { error });
|
|
264
|
-
this.screenReaderEnabled$.next(false);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
198
|
+
document.addEventListener(
|
|
199
|
+
"VIZIO_TTS_DISABLED",
|
|
200
|
+
() => {
|
|
201
|
+
this.ttsState$.next(false);
|
|
202
|
+
},
|
|
203
|
+
false
|
|
204
|
+
);
|
|
267
205
|
}
|
|
268
206
|
|
|
269
207
|
getCurrentState(): boolean {
|
|
@@ -274,38 +212,17 @@ export class TTSManager {
|
|
|
274
212
|
return this.ttsState$.asObservable();
|
|
275
213
|
}
|
|
276
214
|
|
|
277
|
-
getScreenReaderEnabledAsObservable() {
|
|
278
|
-
return this.screenReaderEnabled$.asObservable();
|
|
279
|
-
}
|
|
280
|
-
|
|
281
215
|
readText(text: string) {
|
|
282
216
|
this.ttsState$.next(true);
|
|
283
217
|
|
|
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
|
-
};
|
|
218
|
+
if (isSamsungPlatform() && window.speechSynthesis) {
|
|
219
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
300
220
|
|
|
301
|
-
|
|
302
|
-
|
|
221
|
+
window.speechSynthesis.cancel(); // Cancel previous speech before speaking new text
|
|
222
|
+
window.speechSynthesis.speak(utterance);
|
|
303
223
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
log_debug("Samsung TTS speak() error", { error });
|
|
307
|
-
this.ttsState$.next(false);
|
|
308
|
-
}
|
|
224
|
+
// Estimate reading time and set inactive when done
|
|
225
|
+
this.scheduleTTSComplete(text);
|
|
309
226
|
}
|
|
310
227
|
|
|
311
228
|
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[]
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { Player } from "./player";
|
|
3
3
|
import { usePlayer } from "./usePlayer";
|
|
4
4
|
|
|
5
|
-
type PlayerState = {
|
|
5
|
+
export type PlayerState = {
|
|
6
6
|
currentTime: number;
|
|
7
7
|
duration: number;
|
|
8
8
|
seekableDuration: number;
|
|
@@ -10,6 +10,8 @@ type PlayerState = {
|
|
|
10
10
|
isPaused: boolean;
|
|
11
11
|
isBuffering: boolean;
|
|
12
12
|
isReadyToPlay: boolean;
|
|
13
|
+
trackState?: QuickBrickPlayer.TracksState;
|
|
14
|
+
isAd: boolean;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export const usePlayerState = (
|
|
@@ -24,6 +26,8 @@ export const usePlayerState = (
|
|
|
24
26
|
isPaused: null,
|
|
25
27
|
isBuffering: false,
|
|
26
28
|
isReadyToPlay: false,
|
|
29
|
+
trackState: null,
|
|
30
|
+
isAd: false,
|
|
27
31
|
});
|
|
28
32
|
|
|
29
33
|
const player: Player = usePlayer(playerId);
|
|
@@ -37,6 +41,8 @@ export const usePlayerState = (
|
|
|
37
41
|
isPaused: player.isPaused(),
|
|
38
42
|
isBuffering: player.isBuffering(),
|
|
39
43
|
isReadyToPlay: player.isReadyToPlay(),
|
|
44
|
+
trackState: player.getTracksState(),
|
|
45
|
+
isAd: player.isAd(),
|
|
40
46
|
});
|
|
41
47
|
}, [player]);
|
|
42
48
|
|
|
@@ -54,10 +60,16 @@ export const usePlayerState = (
|
|
|
54
60
|
onPlayerPause: onPlayerChangeState,
|
|
55
61
|
onPlayerResume: onPlayerChangeState,
|
|
56
62
|
onPlayerSeekComplete: onPlayerChangeState,
|
|
63
|
+
onTracksChanged: onPlayerChangeState,
|
|
64
|
+
onAdBreakBegin: onPlayerChangeState,
|
|
65
|
+
onAdBreakEnd: onPlayerChangeState,
|
|
66
|
+
onAdBegin: onPlayerChangeState,
|
|
67
|
+
onAdEnd: onPlayerChangeState,
|
|
68
|
+
onAdError: onPlayerChangeState,
|
|
57
69
|
},
|
|
58
70
|
});
|
|
59
71
|
}
|
|
60
|
-
}, [player]);
|
|
72
|
+
}, [listenerId, onPlayerChangeState, player]);
|
|
61
73
|
|
|
62
74
|
return state;
|
|
63
75
|
};
|
package/cellUtils/index.ts
CHANGED
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
} from "@applicaster/zapp-react-native-utils/stringUtils";
|
|
10
10
|
import { cellUtilsLogger } from "@applicaster/zapp-react-native-utils/cellUtils/logger";
|
|
11
11
|
import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
12
|
-
import {
|
|
13
|
-
isNotNil,
|
|
14
|
-
isNilOrEmpty,
|
|
15
|
-
} from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
12
|
+
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
16
13
|
|
|
17
14
|
import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
|
|
18
15
|
|
|
@@ -508,39 +505,3 @@ export const getImageContainerMarginStyles = ({ value }: { value: any }) => {
|
|
|
508
505
|
marginRight: value("image_margin_right"),
|
|
509
506
|
};
|
|
510
507
|
};
|
|
511
|
-
|
|
512
|
-
export const withoutNilOrEmpty = (arr: string[]): string[] =>
|
|
513
|
-
arr.filter((item) => !isNilOrEmpty(item));
|
|
514
|
-
|
|
515
|
-
export const isTextLabel = (key: string): boolean =>
|
|
516
|
-
key.includes("text_label_") && key.endsWith("_switch");
|
|
517
|
-
|
|
518
|
-
export const hasTextLabelsEnabled = (
|
|
519
|
-
configuration: Record<string, any>
|
|
520
|
-
): boolean => {
|
|
521
|
-
const textLabelsKeys = Object.keys(configuration).filter(isTextLabel);
|
|
522
|
-
|
|
523
|
-
const picked = textLabelsKeys.reduce(
|
|
524
|
-
(acc, key) => {
|
|
525
|
-
acc[key] = configuration[key];
|
|
526
|
-
|
|
527
|
-
return acc;
|
|
528
|
-
},
|
|
529
|
-
{} as Record<string, any>
|
|
530
|
-
);
|
|
531
|
-
|
|
532
|
-
const pickedValues = Object.values(picked);
|
|
533
|
-
|
|
534
|
-
// Check if any switch value is truthy (true, "true", "1", etc.)
|
|
535
|
-
return pickedValues.some((value) => {
|
|
536
|
-
if (typeof value === "boolean") {
|
|
537
|
-
return value === true;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if (typeof value === "string") {
|
|
541
|
-
return value !== "" && value.toLowerCase() !== "false";
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
return Boolean(value);
|
|
545
|
-
});
|
|
546
|
-
};
|
|
@@ -335,6 +335,13 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
335
335
|
};
|
|
336
336
|
|
|
337
337
|
if (isTV(platform)) {
|
|
338
|
+
localizations.fields.push({
|
|
339
|
+
key: "back_to_live_label",
|
|
340
|
+
label: "Back to live label",
|
|
341
|
+
initial_value: "Back To Live",
|
|
342
|
+
type: "text_input",
|
|
343
|
+
});
|
|
344
|
+
|
|
338
345
|
styles.fields.push(
|
|
339
346
|
fieldsGroup("Always Show Scrub Bar & Timestamp", "", [
|
|
340
347
|
{
|
|
@@ -447,7 +454,7 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
447
454
|
),
|
|
448
455
|
fieldsGroup(
|
|
449
456
|
"Skip Button",
|
|
450
|
-
"This section allows you to configure the skip button
|
|
457
|
+
"This section allows you to configure the skip button behaviour",
|
|
451
458
|
[
|
|
452
459
|
{
|
|
453
460
|
type: "switch",
|
|
@@ -464,6 +471,12 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
464
471
|
label: "Persistent Button Toggle",
|
|
465
472
|
initial_value: true,
|
|
466
473
|
},
|
|
474
|
+
]
|
|
475
|
+
),
|
|
476
|
+
fieldsGroup(
|
|
477
|
+
"Labeled Button Style",
|
|
478
|
+
"This section allows you to configure the labeled button styles",
|
|
479
|
+
[
|
|
467
480
|
{
|
|
468
481
|
type: "color_picker_rgba",
|
|
469
482
|
label_tooltip: "",
|
|
@@ -619,6 +632,44 @@ function getPlayerConfiguration({ platform, version }) {
|
|
|
619
632
|
);
|
|
620
633
|
}
|
|
621
634
|
|
|
635
|
+
if (isTV(platform)) {
|
|
636
|
+
general.fields.push(
|
|
637
|
+
{
|
|
638
|
+
key: "liveSeekingEnabled",
|
|
639
|
+
label: "Live Seeking Enabled",
|
|
640
|
+
initial_value: false,
|
|
641
|
+
type: "switch",
|
|
642
|
+
label_tooltip: "Enable Live Seek",
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
key: "minimumAllowedSeekableDurationInSeconds",
|
|
646
|
+
label: "Minimum allowed seekable duration in seconds",
|
|
647
|
+
initial_value: 300,
|
|
648
|
+
type: "number_input",
|
|
649
|
+
label_tooltip:
|
|
650
|
+
"If duration less than this value, player will disable 'liveSeekingEnabled' value",
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
key: "live_image",
|
|
654
|
+
label: "Live badge",
|
|
655
|
+
type: "uploader",
|
|
656
|
+
label_tooltip: "Override default live badge / icon",
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
key: "live_width",
|
|
660
|
+
label: "Live badge width",
|
|
661
|
+
type: "number_input",
|
|
662
|
+
initial_value: 85,
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
key: "live_height",
|
|
666
|
+
label: "Live badge height",
|
|
667
|
+
type: "number_input",
|
|
668
|
+
initial_value: 50,
|
|
669
|
+
}
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
|
|
622
673
|
if (isMobile(platform)) {
|
|
623
674
|
general.fields.push(
|
|
624
675
|
{
|
package/manifestUtils/keys.js
CHANGED
|
@@ -959,6 +959,27 @@ const TV_CELL_LABEL_FIELDS = [
|
|
|
959
959
|
rules: "conditional",
|
|
960
960
|
conditions: [{ key: "switch", section: "styles", value: true }],
|
|
961
961
|
},
|
|
962
|
+
{
|
|
963
|
+
type: ZAPPIFEST_FIELDS.font_selector.roku,
|
|
964
|
+
suffix: "roku font family",
|
|
965
|
+
tooltip: "",
|
|
966
|
+
rules: "conditional",
|
|
967
|
+
conditions: [{ key: "switch", section: "styles", value: true }],
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
type: ZAPPIFEST_FIELDS.number_input,
|
|
971
|
+
suffix: "roku font size",
|
|
972
|
+
tooltip: "",
|
|
973
|
+
rules: "conditional",
|
|
974
|
+
conditions: [{ key: "switch", section: "styles", value: true }],
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
type: ZAPPIFEST_FIELDS.number_input,
|
|
978
|
+
suffix: "roku line height",
|
|
979
|
+
tooltip: "",
|
|
980
|
+
rules: "conditional",
|
|
981
|
+
conditions: [{ key: "switch", section: "styles", value: true }],
|
|
982
|
+
},
|
|
962
983
|
{
|
|
963
984
|
type: ZAPPIFEST_FIELDS.select,
|
|
964
985
|
suffix: "text alignment",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.9331298916",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.9331298916",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -147,17 +147,34 @@ export class TVSeekController
|
|
|
147
147
|
|
|
148
148
|
let targetPos = currentPos;
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
const isLive = this.playerController.isLive();
|
|
151
|
+
|
|
152
|
+
if (isLive) {
|
|
153
|
+
if (this.currentSeekType === SEEK_TYPE.REWIND) {
|
|
154
|
+
targetPos = Math.min(
|
|
155
|
+
currentPos + offset,
|
|
156
|
+
this.playerController.getSeekableDuration()
|
|
157
|
+
);
|
|
158
|
+
} else if (this.currentSeekType === SEEK_TYPE.FORWARD) {
|
|
159
|
+
targetPos = Math.max(0, currentPos - offset);
|
|
160
|
+
} else {
|
|
161
|
+
log_warning(
|
|
162
|
+
`TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
157
165
|
} else {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
if (this.currentSeekType === SEEK_TYPE.FORWARD) {
|
|
167
|
+
targetPos = Math.min(
|
|
168
|
+
currentPos + offset,
|
|
169
|
+
this.playerController.getSeekableDuration()
|
|
170
|
+
);
|
|
171
|
+
} else if (this.currentSeekType === SEEK_TYPE.REWIND) {
|
|
172
|
+
targetPos = Math.max(0, currentPos - offset);
|
|
173
|
+
} else {
|
|
174
|
+
log_warning(
|
|
175
|
+
`TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
161
178
|
}
|
|
162
179
|
|
|
163
180
|
log_debug(
|