@applicaster/zapp-react-native-utils 12.0.0-alpha.5227180498 → 12.0.0-alpha.5347482137

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.
Files changed (45) hide show
  1. package/analyticsUtils/AnalyticsEvents/index.ts +7 -0
  2. package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
  3. package/analyticsUtils/analyticsPlugins.ts +25 -0
  4. package/analyticsUtils/events.ts +6 -0
  5. package/analyticsUtils/index.tsx +6 -0
  6. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
  7. package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
  8. package/appUtils/focusManager/__tests__/index.test.ts +2 -3
  9. package/appUtils/focusManager/index.ts +76 -56
  10. package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -44
  11. package/appUtils/focusManager/utils/index.ts +100 -0
  12. package/appUtils/focusManagerAux/index.ts +76 -0
  13. package/appUtils/focusManagerAux/utils/index.ts +100 -0
  14. package/appUtils/keyCodes/keys.web.js +1 -1
  15. package/appUtils/platform/const.ts +25 -0
  16. package/appUtils/platform/index.ts +3 -0
  17. package/appUtils/platform/platformUtils.ts +223 -0
  18. package/appUtils/playerManager/conts.ts +1 -0
  19. package/appUtils/playerManager/index.ts +11 -5
  20. package/appUtils/playerManager/nativePlayerManager.ts +12 -0
  21. package/appUtils/playerManager/player.ts +8 -3
  22. package/appUtils/playerManager/playerNative.ts +5 -14
  23. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -1
  24. package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
  25. package/arrayUtils/index.ts +5 -0
  26. package/booleanUtils/index.ts +4 -4
  27. package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
  28. package/numberUtils/index.ts +5 -18
  29. package/package.json +2 -2
  30. package/reactHooks/cell-click/__tests__/index.test.js +10 -1
  31. package/reactHooks/cell-click/index.ts +12 -12
  32. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
  33. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
  34. package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
  35. package/reactHooks/feed/useFeedRefresh.tsx +9 -7
  36. package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
  37. package/reactHooks/navigation/index.ts +56 -67
  38. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
  39. package/reactHooks/screen/index.ts +2 -0
  40. package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
  41. package/reactHooks/screen/useScreenContext.ts +2 -2
  42. package/reactUtils/index.ts +102 -0
  43. package/appUtils/focusManager/FocusableEvents.ts +0 -8
  44. package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
  45. package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
@@ -0,0 +1,76 @@
1
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
2
+ import { find, path } from "ramda";
3
+
4
+ import {
5
+ waitForActiveScreen,
6
+ waitForContent,
7
+ getContentNode,
8
+ getNavbarNode,
9
+ } from "./utils";
10
+
11
+ import { coreLogger } from "../../logger";
12
+
13
+ const logger = coreLogger.addSubsystem("focusManagerAux");
14
+
15
+ export async function setFocusOnMenu(currentRoute: string) {
16
+ const { setFocus, focusableTree } = focusManager;
17
+
18
+ try {
19
+ await waitForActiveScreen(currentRoute, focusableTree);
20
+
21
+ const navbar = getNavbarNode(focusableTree);
22
+
23
+ const selectedMenuItemId = find(
24
+ (child) => child.component.props.selected,
25
+ navbar.children
26
+ )?.id;
27
+
28
+ if (selectedMenuItemId) {
29
+ // set focus on selected menu item
30
+ setFocus(selectedMenuItemId);
31
+
32
+ return;
33
+ }
34
+
35
+ const firstMenuItemId = path(["children", 0, "id"], navbar);
36
+
37
+ if (firstMenuItemId) {
38
+ // set focus on first menu item
39
+ setFocus(firstMenuItemId);
40
+ }
41
+ } catch (error) {
42
+ logger.log({
43
+ message: "setFocusOnMenu – failed to put focus on top-menu",
44
+ data: {
45
+ currentRoute,
46
+ error,
47
+ },
48
+ });
49
+ }
50
+ }
51
+
52
+ export async function setFocusOnContent(currentRoute: string) {
53
+ // we need to put focus on content here
54
+ // For doing it we have to wait registration of first focusable node into focusableTree
55
+ // we wait until content node starts having children
56
+
57
+ const { setInitialFocus, focusableTree } = focusManager;
58
+
59
+ try {
60
+ await waitForActiveScreen(currentRoute, focusableTree);
61
+ await waitForContent(focusableTree);
62
+
63
+ const content = getContentNode(focusableTree);
64
+
65
+ const { success } = setInitialFocus(content);
66
+
67
+ if (!success) {
68
+ // we've failed to put initial focus on content, re-run "setFocusOnContent" again as a fallback
69
+ throw Error(
70
+ "we've failed to put initial focus on content, re-run 'setFocusOnContent' again as a fallback"
71
+ );
72
+ }
73
+ } catch (error) {
74
+ setFocusOnContent(currentRoute);
75
+ }
76
+ }
@@ -0,0 +1,100 @@
1
+ import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
2
+ import { find, last, startsWith, pathOr } from "ramda";
3
+ import {
4
+ QUICK_BRICK_NAVBAR,
5
+ QUICK_BRICK_CONTENT,
6
+ } from "@applicaster/quick-brick-core/const";
7
+
8
+ // run check each 300 ms
9
+ // run this check too often could lead to performance penalty on low-end devices
10
+ const HOW_OFTEN_TO_CHECK_CONDITION = 300; // ms
11
+
12
+ type Props = {
13
+ maxTimeout: number;
14
+ conditionFn: () => boolean;
15
+ };
16
+
17
+ export const waitUntil = ({ maxTimeout, conditionFn }: Props) => {
18
+ let interval;
19
+ let timeout;
20
+
21
+ return new Promise((resolve, reject) => {
22
+ // run interval check
23
+ interval = setInterval(() => {
24
+ if (conditionFn()) {
25
+ clearInterval(interval);
26
+ clearTimeout(timeout);
27
+
28
+ resolve(undefined);
29
+ }
30
+ }, HOW_OFTEN_TO_CHECK_CONDITION);
31
+
32
+ // max timeout when we need to stop interval check
33
+ timeout = setTimeout(() => {
34
+ clearInterval(interval);
35
+ clearTimeout(timeout);
36
+
37
+ const error = Error(
38
+ "Failed to wait satisfy condition. Max timeout is reached."
39
+ );
40
+
41
+ reject(error);
42
+ }, maxTimeout);
43
+ });
44
+ };
45
+
46
+ export const waitForActiveScreen = (currentRoute: string, focusableTree) => {
47
+ const isActiveScreenAvailableToFocus = (): boolean => {
48
+ const routes = focusableTree.root.children;
49
+
50
+ const route = find((route) => route.id === currentRoute, routes);
51
+
52
+ return isNotNil(route);
53
+ };
54
+
55
+ return waitUntil({
56
+ maxTimeout: HOW_OFTEN_TO_CHECK_CONDITION * 10, // ms
57
+ conditionFn: isActiveScreenAvailableToFocus,
58
+ });
59
+ };
60
+
61
+ const getActiveScreenChildren = (focusableTree) => {
62
+ return pathOr([], ["children"], last(focusableTree.root.children));
63
+ };
64
+
65
+ export const getContentNode = (focusableTree) => {
66
+ const content = find(
67
+ (child) =>
68
+ startsWith(QUICK_BRICK_CONTENT, child.id) ||
69
+ startsWith("player", child.id),
70
+ getActiveScreenChildren(focusableTree)
71
+ );
72
+
73
+ return content;
74
+ };
75
+
76
+ export const getNavbarNode = (focusableTree) => {
77
+ const navbar = find(
78
+ (child) => startsWith(QUICK_BRICK_NAVBAR, child.id),
79
+ getActiveScreenChildren(focusableTree)
80
+ );
81
+
82
+ return navbar;
83
+ };
84
+
85
+ export const waitForContent = (focusableTree) => {
86
+ const contentHasAnyChildren = (): boolean => {
87
+ const countOfChildren = pathOr(
88
+ 0,
89
+ ["children", "length"],
90
+ getContentNode(focusableTree)
91
+ );
92
+
93
+ return countOfChildren > 0;
94
+ };
95
+
96
+ return waitUntil({
97
+ maxTimeout: HOW_OFTEN_TO_CHECK_CONDITION * 10, // ms
98
+ conditionFn: contentHasAnyChildren,
99
+ });
100
+ };
@@ -1,7 +1,7 @@
1
1
  /* global tizen */
2
2
  const isTizen = typeof tizen !== "undefined";
3
3
 
4
- import { isVizioPlatform } from "@applicaster/zapp-react-dom-app/App/Loader/utils/platform";
4
+ import { isVizioPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
  import * as platformKeys from "./keysByPlatform";
6
6
  import { Platform } from "react-native";
7
7
 
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Platforms found in userAgent string, please note that simulators
3
+ * might not have the same agents that the devices have
4
+ */
5
+ export const PLATFORMS = {
6
+ webos: "Web0S",
7
+ tizen: "Tizen",
8
+ samsung: "SMART-TV",
9
+ mac: "Mac",
10
+ win: "Win",
11
+ linux: "Linux",
12
+ iphone: "iPhone",
13
+ android: "Android",
14
+ mobile: "Mobile",
15
+ vizio: "VIZIO",
16
+ smartcast: "SmartCast",
17
+ conjure: "Conjure",
18
+ };
19
+
20
+ /**
21
+ * Keys used to store the platform / device state in the session storage
22
+ */
23
+ export const PLATFORM_KEYS = {
24
+ deviceClosedCaptioningEnabled: "device_closed_captioning_enabled",
25
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./platformUtils";
2
+
3
+ export * from "./const";
@@ -0,0 +1,223 @@
1
+ import { BehaviorSubject } from "rxjs";
2
+
3
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
4
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
5
+ import { PlayerWebController } from "@applicaster/zapp-react-native-default-player/src/playerFactory/players/playerWebController";
6
+
7
+ import { PLATFORM_KEYS, PLATFORMS } from "./const";
8
+ import { createLogger, utilsLogger } from "../../logger";
9
+
10
+ declare global {
11
+ interface Window {
12
+ VIZIO?: {
13
+ exitApplication: () => void;
14
+ setClosedCaptionHandler: (
15
+ callback: (isCCEnabled: boolean) => void
16
+ ) => void;
17
+ };
18
+ }
19
+ }
20
+
21
+ const { log_debug, log_error } = createLogger({
22
+ category: "General",
23
+ subsystem: "PlatformUtils",
24
+ parent: utilsLogger,
25
+ });
26
+
27
+ export const getUserAgent = () =>
28
+ window?.navigator?.userAgent || global?.navigator?.userAgent;
29
+
30
+ /** VIZIO UTILS */
31
+
32
+ /**
33
+ * Checks if we are on the Vizio platform by using the userAgent string
34
+ *
35
+ * Use this method when you need to identify the platform on runtime
36
+ * before the VIZIO Companion Library has loaded
37
+ */
38
+ export const isVizioPlatform = () => {
39
+ const userAgent = getUserAgent();
40
+
41
+ const isVizioAgent =
42
+ userAgent.includes(PLATFORMS.vizio) ||
43
+ userAgent.includes(PLATFORMS.smartcast) ||
44
+ userAgent.includes(PLATFORMS.conjure);
45
+
46
+ return isVizioAgent;
47
+ };
48
+
49
+ /**
50
+ * Checks if we are on the Vizio platform by checking for the global VIZIO object
51
+ * and the VIZIO Companion Library. This method does not use the userAgent string,
52
+ * because it mainly checks whether we have access to apis, which may not be available yet
53
+ */
54
+ export const hasVizioAPIs = () => {
55
+ const hasAPIs =
56
+ typeof window.VIZIO !== "undefined" &&
57
+ window?.applicaster?.vizioLibraryDidLoad;
58
+
59
+ return hasAPIs;
60
+ };
61
+
62
+ /**
63
+ * Manages device based closed captioning state
64
+ * Returns an observable that emits the current state and updates whenever it changes
65
+ */
66
+ class ClosedCaptioningManager {
67
+ private ccState$ = new BehaviorSubject<boolean>(false);
68
+ private static ccManagerInstance: ClosedCaptioningManager;
69
+
70
+ private constructor() {
71
+ this.initialize();
72
+ }
73
+
74
+ static getInstance(): ClosedCaptioningManager {
75
+ if (!ClosedCaptioningManager.ccManagerInstance) {
76
+ ClosedCaptioningManager.ccManagerInstance = new ClosedCaptioningManager();
77
+ }
78
+
79
+ return ClosedCaptioningManager.ccManagerInstance;
80
+ }
81
+
82
+ async initialize() {
83
+ const existingState = await sessionStorage.getItem(
84
+ PLATFORM_KEYS.deviceClosedCaptioningEnabled
85
+ );
86
+
87
+ log_debug("Initializing closed captioning manager", { existingState });
88
+
89
+ if (existingState !== null) {
90
+ this.ccState$.next(existingState === "true" || existingState === true);
91
+ }
92
+
93
+ if (hasVizioAPIs()) {
94
+ window.VIZIO!.setClosedCaptionHandler((isCCEnabled) => {
95
+ log_debug("CC state changed", { isCCEnabled });
96
+
97
+ sessionStorage.setItem(
98
+ PLATFORM_KEYS.deviceClosedCaptioningEnabled,
99
+ isCCEnabled
100
+ );
101
+
102
+ this.ccState$.next(isCCEnabled);
103
+ });
104
+ }
105
+ }
106
+
107
+ getCurrentState(): boolean {
108
+ return this.ccState$.getValue();
109
+ }
110
+
111
+ getStateAsObservable() {
112
+ return this.ccState$.asObservable();
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Subscribe to closed captioning state changes
118
+ * @returns Observable<boolean>
119
+ * @example
120
+ * const subscription = getClosedCaptionState().subscribe(
121
+ * isEnabled => setClosedCaptionState(isEnabled)
122
+ * );
123
+ * subscription.unsubscribe(), []);
124
+ */
125
+ export const getClosedCaptionState = () => {
126
+ const ccManager = ClosedCaptioningManager.getInstance();
127
+
128
+ return ccManager.getStateAsObservable();
129
+ };
130
+
131
+ export class TextTrackManager {
132
+ private controller?: PlayerWebController;
133
+ private static instance: TextTrackManager;
134
+
135
+ private constructor() {}
136
+
137
+ static getInstance(): TextTrackManager {
138
+ if (!TextTrackManager.instance) {
139
+ TextTrackManager.instance = new TextTrackManager();
140
+ }
141
+
142
+ return TextTrackManager.instance;
143
+ }
144
+
145
+ initialize(controller: PlayerWebController) {
146
+ if (!controller) {
147
+ throw new Error(
148
+ "Controller is required for TextTrackManager initialization"
149
+ );
150
+ }
151
+
152
+ this.controller = controller;
153
+ }
154
+
155
+ async setTextTrackBasedOnCaptions(closedCaptionsState: boolean) {
156
+ if (!this.controller) {
157
+ log_error("Controller is not initialized");
158
+
159
+ return;
160
+ }
161
+
162
+ if (closedCaptionsState) {
163
+ const textTracks = this.controller.getTracksState().textTracks;
164
+ const preferredTextTrack = await this.getPreferredTextTrack(textTracks);
165
+
166
+ if (preferredTextTrack) {
167
+ this.controller.selectTrack(preferredTextTrack);
168
+ }
169
+ } else {
170
+ this.controller.selectTrack(null);
171
+ }
172
+ }
173
+
174
+ async getPreferredTextTrack(
175
+ textTracks: QuickBrickPlayer.TextTrack[]
176
+ ): Promise<QuickBrickPlayer.TextTrack | undefined> {
177
+ if (!this.controller) return;
178
+
179
+ const userPreferredTextLanguageLocalStorage = await localStorage.getItem(
180
+ "preferred_text_language",
181
+ "user_preferences"
182
+ );
183
+
184
+ let userPreferredTextLanguage;
185
+
186
+ if (userPreferredTextLanguageLocalStorage) {
187
+ userPreferredTextLanguage = textTracks.find(
188
+ (track) => track.language === userPreferredTextLanguageLocalStorage
189
+ );
190
+ }
191
+
192
+ if (userPreferredTextLanguage?.id) {
193
+ return userPreferredTextLanguage;
194
+ }
195
+
196
+ const enableAutoTextTrackSelection =
197
+ this.controller.getPluginConfiguration()
198
+ ?.enable_auto_text_track_selection ||
199
+ this.controller.getTracksState().textTracks.length > 0;
200
+
201
+ if (enableAutoTextTrackSelection) {
202
+ const languageCode = await sessionStorage.getItem("languageCode");
203
+
204
+ if (languageCode) {
205
+ const chosenTextTrackBySystemLanguage = textTracks.find(
206
+ (track) => track.language === languageCode
207
+ );
208
+
209
+ if (chosenTextTrackBySystemLanguage?.id) {
210
+ return chosenTextTrackBySystemLanguage;
211
+ }
212
+ }
213
+ }
214
+
215
+ return textTracks?.[0];
216
+ }
217
+
218
+ isTextTrackEnabled(): boolean {
219
+ if (!this.controller) return false;
220
+
221
+ return this.controller.getTracksState().textTrackId !== null;
222
+ }
223
+ }
@@ -7,6 +7,7 @@ export enum SharedPlayerCallBacksKeys {
7
7
  OnPlayerPause = "onPlayerPause",
8
8
  OnLoad = "onLoad",
9
9
  OnError = "onError",
10
+ OnVideoError = "onVideoError",
10
11
  OnVideoEnd = "onVideoEnd",
11
12
  OnPlaybackRateChange = "onPlaybackRateChange",
12
13
  OnVideoLoad = "onVideoLoad",
@@ -11,6 +11,7 @@ import {
11
11
  } from "@applicaster/quick-brick-core/App/NetworkStatusProvider/utils";
12
12
  import { setUserLanguagePreference } from "./userLanguagePreference";
13
13
  import { PlayerRole } from "./conts";
14
+ import { RNPlayerManager } from "./nativePlayerManager";
14
15
 
15
16
  const { log_error, log_debug, log_warning } = createLogger({
16
17
  category: "General",
@@ -164,6 +165,10 @@ export class PlayerManager {
164
165
  this.addPlayer(id, playerController);
165
166
 
166
167
  if (playerController.playerRole === PlayerRole.Primary) {
168
+ if (playerController.playerPluginId !== "QuickBrickPlayerPlugin") {
169
+ RNPlayerManager?.["QuickBrickPlayerPlugin"]?.stopBackgroundPlayback?.();
170
+ }
171
+
167
172
  playerController.addListener({
168
173
  id: this.getPlayerListenerId(id),
169
174
  listener: {
@@ -361,9 +366,9 @@ export class PlayerManager {
361
366
  // TODO: Remove
362
367
  if (this.castingReceiver) {
363
368
  this.castingReceiver.rewind(deltaTime);
369
+ } else {
370
+ this.getActivePlayer()?.rewind(deltaTime);
364
371
  }
365
-
366
- this.getActivePlayer()?.rewind(deltaTime);
367
372
  }
368
373
 
369
374
  public forward(deltaTime = null) {
@@ -371,9 +376,9 @@ export class PlayerManager {
371
376
 
372
377
  if (this.castingReceiver) {
373
378
  this.castingReceiver.forward(deltaTime);
379
+ } else {
380
+ this.getActivePlayer()?.forward(deltaTime);
374
381
  }
375
-
376
- this.getActivePlayer()?.forward(deltaTime);
377
382
  }
378
383
 
379
384
  public seeking(time) {
@@ -436,7 +441,7 @@ export class PlayerManager {
436
441
  }
437
442
 
438
443
  // Call method on player just in case
439
- return this.getActivePlayer()?.setLanguage(track);
444
+ return this.getActivePlayer()?.selectTrack(track);
440
445
  }
441
446
 
442
447
  public isRegistered() {
@@ -461,6 +466,7 @@ export class PlayerManager {
461
466
  if (this.castingReceiver) {
462
467
  this.castingReceiver.closeNativePlayer();
463
468
  } else {
469
+ this.getActivePlayer().closeNativePlayer();
464
470
  this.invokeHandler("close");
465
471
  }
466
472
  }
@@ -0,0 +1,12 @@
1
+ import { NativeModules } from "react-native";
2
+ import { isApplePlatform } from "../../reactUtils";
3
+
4
+ export const RNPlayerManager = {
5
+ QuickBrickPlayerPlugin: isApplePlatform()
6
+ ? NativeModules.PlayerModule
7
+ : NativeModules.QuickBrickDefaultPlayerModule,
8
+ KalturaPlayerPlugin: isApplePlatform()
9
+ ? NativeModules.KalturaPlayerModule
10
+ : NativeModules.QBKalturaPlayerModule,
11
+ "quick-brick-player-brightcove": NativeModules.BrightcovePlayerModule,
12
+ };
@@ -359,6 +359,13 @@ export class Player {
359
359
  });
360
360
  };
361
361
 
362
+ onVideoError = (error: Error) => {
363
+ this.invokeListenersUpdate({
364
+ callbackName: SharedPlayerCallBacksKeys.OnVideoError,
365
+ event: error,
366
+ });
367
+ };
368
+
362
369
  onError = (error: Error) => {
363
370
  this.invokeListenersUpdate({
364
371
  callbackName: SharedPlayerCallBacksKeys.OnError,
@@ -650,6 +657,7 @@ export class Player {
650
657
  onPlayerSeekComplete: this.onSeekComplete,
651
658
  onVideoEnd: this.onVideoEnd,
652
659
  onError: this.onError,
660
+ onVideoError: this.onVideoError,
653
661
  onLoad: this.onLoad,
654
662
  onPlayerPause: this.onPlayerPause,
655
663
  onPlayerResume: this.onPlayerResume,
@@ -684,9 +692,6 @@ export class Player {
684
692
  play = () => {};
685
693
  pause = () => {};
686
694
  disableBufferAnimation = (): boolean => true;
687
- setLanguage = (
688
- _selected?: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
689
- ) => {};
690
695
 
691
696
  setPlaybackRate = (_rate) => {};
692
697
  startSleepTimer = (_timestamp) => {};
@@ -2,19 +2,10 @@ import * as R from "ramda";
2
2
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
3
3
  import { createLogger, utilsLogger } from "../../logger";
4
4
  import { Player } from "./player";
5
- import { findNodeHandle, NativeModules } from "react-native";
6
- import { isApplePlatform } from "../../reactUtils";
5
+ import { findNodeHandle } from "react-native";
7
6
  import { PlayerRole } from "./conts";
8
7
  import { toBooleanWithDefaultFalse } from "../../booleanUtils";
9
-
10
- const RNPlayerManager = {
11
- QuickBrickPlayerPlugin: isApplePlatform()
12
- ? NativeModules.PlayerModule
13
- : NativeModules.QuickBrickDefaultPlayerModule,
14
- KalturaPlayerPlugin: isApplePlatform()
15
- ? NativeModules.KalturaPlayerModule
16
- : NativeModules.QBKalturaPlayerModule,
17
- };
8
+ import { RNPlayerManager } from "./nativePlayerManager";
18
9
 
19
10
  const logger = createLogger({
20
11
  category: "PlayerNativeController",
@@ -111,7 +102,7 @@ export class PlayerNative extends Player {
111
102
  return;
112
103
  }
113
104
 
114
- const newPosition = R.clamp(0, position, this.playerState.seekableDuration);
105
+ const newPosition = R.clamp(0, this.playerState.seekableDuration, position);
115
106
 
116
107
  if (
117
108
  !this.invokeNativeFunction(
@@ -197,10 +188,10 @@ export class PlayerNative extends Player {
197
188
 
198
189
  disableBufferAnimation = (): boolean => false;
199
190
 
200
- setLanguage = (
191
+ selectTrack = (
201
192
  selected: QuickBrickPlayer.TextTrack | QuickBrickPlayer.AudioTrack
202
193
  ) => {
203
- this.currentPlayerComponent()?.["setLanguage"]?.(selected);
194
+ this.currentPlayerComponent()?.["selectTrack"]?.(selected);
204
195
  };
205
196
 
206
197
  setPlaybackRate = (rate: number) => {
@@ -4,6 +4,7 @@ import { useEffect } from "react";
4
4
  import { playerManager } from "./index";
5
5
  import { useValidatePlayerConfig } from "../../playerUtils/useValidatePlayerConfig";
6
6
  import { PlayerRole } from "./conts";
7
+ import { isAppleTV } from "@applicaster/zapp-react-native-ui-components/Helpers/Platform";
7
8
 
8
9
  // TODO: Rename to ControllerType
9
10
  export const usePlayerControllerSetup = ({
@@ -34,10 +35,14 @@ export const usePlayerControllerSetup = ({
34
35
  useValidatePlayerConfig(config);
35
36
 
36
37
  useEffect(() => {
38
+ const newConfig = isAppleTV()
39
+ ? { supports_native_controls: true, ...config }
40
+ : config;
41
+
37
42
  const newPlayerController = new ControllerType({
38
43
  player: ref,
39
44
  listener: props as any,
40
- config,
45
+ config: newConfig,
41
46
  playerId,
42
47
  entry,
43
48
  playerPluginId: pluginId,
@@ -0,0 +1,63 @@
1
+ import { isFilledArray } from "..";
2
+
3
+ describe("isFilledArray", () => {
4
+ it("non-empty array is not empty", () => {
5
+ const value = [1, 2, 3];
6
+
7
+ expect(isFilledArray(value)).toBe(true);
8
+ });
9
+
10
+ it("empty array is empty", () => {
11
+ const value = [];
12
+
13
+ expect(isFilledArray(value)).toBe(false);
14
+ });
15
+
16
+ it("number is not array", () => {
17
+ const value = 123;
18
+
19
+ expect(isFilledArray(value)).toBe(false);
20
+ });
21
+
22
+ it("string is not array", () => {
23
+ const value = "vfnjdk";
24
+
25
+ expect(isFilledArray(value)).toBe(false);
26
+ });
27
+
28
+ it("empty string is not array", () => {
29
+ const value = "";
30
+
31
+ expect(isFilledArray(value)).toBe(false);
32
+ });
33
+
34
+ it("NaN is not array", () => {
35
+ const value = "";
36
+
37
+ expect(isFilledArray(value)).toBe(false);
38
+ });
39
+
40
+ it("object is not array", () => {
41
+ const value = { test: 1 };
42
+
43
+ expect(isFilledArray(value)).toBe(false);
44
+ });
45
+
46
+ it("empty object is not array", () => {
47
+ const value = {};
48
+
49
+ expect(isFilledArray(value)).toBe(false);
50
+ });
51
+
52
+ it("undefined is not array", () => {
53
+ const value = undefined;
54
+
55
+ expect(isFilledArray(value)).toBe(false);
56
+ });
57
+
58
+ it("null is not array", () => {
59
+ const value = null;
60
+
61
+ expect(isFilledArray(value)).toBe(false);
62
+ });
63
+ });
@@ -95,3 +95,8 @@ export const makeListOfIndexes = (size: number): number[] =>
95
95
  export const makeListOf = (value: unknown, size: number): number[] => {
96
96
  return Array(size).fill(value);
97
97
  };
98
+
99
+ /** Checks if a value is a non-empty array */
100
+ export function isFilledArray(value: unknown): boolean {
101
+ return R.is(Array, value) && R.length(value) > 0;
102
+ }