@applicaster/zapp-react-native-utils 15.0.0-alpha.7877002324 → 15.0.0-alpha.8526950782

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.
@@ -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 trimmed = text.trim();
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
- // Count spaces - multiple consecutive spaces add extra pause time
23
- const spaceMatches: string[] = trimmed.match(/\s+/g) || [];
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,84 +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
- //https://webostv.developer.lge.com/develop/references/settings-service
213
- window.webOS.service.request("luna://com.webos.settingsservice", {
214
- method: "getSystemSettings",
215
- parameters: {
216
- category: "option",
217
- keys: ["audioGuidance"],
218
- subscribe: true, // Request a subscription to changes
219
- },
220
- onSuccess: (response: any) => {
221
- const isEnabled = response?.settings?.audioGuidance === "on";
188
+ if (!isVizioPlatform()) return;
222
189
 
223
- log_debug("LG Audio Guidance status changed", {
224
- isEnabled,
225
- response,
226
- });
227
-
228
- this.screenReaderEnabled$.next(isEnabled);
229
- },
230
- onFailure: (error: any) => {
231
- log_debug("webOS settings subscription failed", { error });
232
- this.screenReaderEnabled$.next(false);
233
- },
234
- });
235
- } catch (error) {
236
- log_debug("webOS settings service request error", { error });
237
- this.screenReaderEnabled$.next(false);
238
- }
239
- }
190
+ document.addEventListener(
191
+ "VIZIO_TTS_ENABLED",
192
+ () => {
193
+ this.ttsState$.next(true);
194
+ },
195
+ false
196
+ );
240
197
 
241
- if (isSamsungPlatform() && typeof window.tizen !== "undefined") {
242
- try {
243
- if (
244
- window.tizen.accessibility &&
245
- typeof window.tizen.accessibility
246
- .addVoiceGuideStatusChangeListener === "function"
247
- ) {
248
- this.samsungListenerId =
249
- window.tizen.accessibility.addVoiceGuideStatusChangeListener(
250
- (enabled: boolean) => {
251
- log_debug("Samsung Voice Guide status changed", { enabled });
252
- this.screenReaderEnabled$.next(!!enabled);
253
- }
254
- );
255
-
256
- log_debug("Samsung Voice Guide listener registered", {
257
- listenerId: this.samsungListenerId,
258
- });
259
- } else {
260
- log_debug("Samsung accessibility API not available");
261
- this.screenReaderEnabled$.next(false);
262
- }
263
- } catch (error) {
264
- log_debug("Samsung Voice Guide listener error", { error });
265
- this.screenReaderEnabled$.next(false);
266
- }
267
- }
198
+ document.addEventListener(
199
+ "VIZIO_TTS_DISABLED",
200
+ () => {
201
+ this.ttsState$.next(false);
202
+ },
203
+ false
204
+ );
268
205
  }
269
206
 
270
207
  getCurrentState(): boolean {
@@ -275,38 +212,17 @@ export class TTSManager {
275
212
  return this.ttsState$.asObservable();
276
213
  }
277
214
 
278
- getScreenReaderEnabledAsObservable() {
279
- return this.screenReaderEnabled$.asObservable();
280
- }
281
-
282
215
  readText(text: string) {
283
216
  this.ttsState$.next(true);
284
217
 
285
- if (
286
- isSamsungPlatform() &&
287
- typeof window.tizen !== "undefined" &&
288
- window.tizen.speech
289
- ) {
290
- try {
291
- const successCallback = () => {
292
- log_debug("Samsung TTS play started successfully");
293
- // Estimate reading time and set inactive when done
294
- this.scheduleTTSComplete(text);
295
- };
296
-
297
- const errorCallback = (error: any) => {
298
- log_debug("Samsung TTS error", { error: error?.message || error });
299
- this.ttsState$.next(false);
300
- };
218
+ if (isSamsungPlatform() && window.speechSynthesis) {
219
+ const utterance = new SpeechSynthesisUtterance(text);
301
220
 
302
- // Clear any previous speech before speaking new text
303
- window.tizen.speech.stop();
221
+ window.speechSynthesis.cancel(); // Cancel previous speech before speaking new text
222
+ window.speechSynthesis.speak(utterance);
304
223
 
305
- window.tizen.speech.speak(text, successCallback, errorCallback);
306
- } catch (error) {
307
- log_debug("Samsung TTS speak() error", { error });
308
- this.ttsState$.next(false);
309
- }
224
+ // Estimate reading time and set inactive when done
225
+ this.scheduleTTSComplete(text);
310
226
  }
311
227
 
312
228
  if (isLgPlatform() && window.webOS?.service) {
@@ -250,6 +250,10 @@ export class Player {
250
250
  return false;
251
251
  }
252
252
 
253
+ if (!Number.isFinite(duration)) {
254
+ return this.getSeekableDuration() > 0;
255
+ }
256
+
253
257
  return duration > 0;
254
258
  };
255
259
 
@@ -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
  };
@@ -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 styles for tv",
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,32 @@ 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 that 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
+ }
660
+
622
661
  if (isMobile(platform)) {
623
662
  general.fields.push(
624
663
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "15.0.0-alpha.7877002324",
3
+ "version": "15.0.0-alpha.8526950782",
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.7877002324",
30
+ "@applicaster/applicaster-types": "15.0.0-alpha.8526950782",
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
- if (this.currentSeekType === SEEK_TYPE.FORWARD) {
151
- targetPos = Math.min(
152
- currentPos + offset,
153
- this.playerController.getSeekableDuration()
154
- );
155
- } else if (this.currentSeekType === SEEK_TYPE.REWIND) {
156
- targetPos = Math.max(0, currentPos - offset);
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
- log_warning(
159
- `TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
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(