@applicaster/zapp-react-native-utils 12.0.0-alpha.5000126055 → 12.0.0-alpha.5001350756

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 (53) hide show
  1. package/analyticsUtils/AnalyticsEvents/index.ts +7 -0
  2. package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
  3. package/analyticsUtils/{playerAnalyticsTracker.ts → analyticsTracker.ts} +10 -19
  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 +8 -0
  15. package/appUtils/keyCodes/keysByPlatform.js +11 -1
  16. package/appUtils/platform/const.ts +25 -0
  17. package/appUtils/platform/index.ts +3 -0
  18. package/appUtils/platform/platformUtils.ts +223 -0
  19. package/appUtils/playerManager/conts.ts +1 -0
  20. package/appUtils/playerManager/index.ts +38 -14
  21. package/appUtils/playerManager/nativePlayerManager.ts +12 -0
  22. package/appUtils/playerManager/player.ts +13 -16
  23. package/appUtils/playerManager/playerNative.ts +6 -16
  24. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -17
  25. package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
  26. package/arrayUtils/index.ts +5 -0
  27. package/booleanUtils/index.ts +4 -4
  28. package/keyboardState/index.ts +0 -0
  29. package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
  30. package/numberUtils/index.ts +5 -18
  31. package/package.json +2 -2
  32. package/reactHooks/cell-click/__tests__/index.test.js +9 -5
  33. package/reactHooks/cell-click/index.ts +11 -11
  34. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
  35. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
  36. package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
  37. package/reactHooks/feed/useFeedRefresh.tsx +9 -7
  38. package/reactHooks/navigation/index.ts +40 -7
  39. package/reactHooks/player/__tests__/useAutoSeek.test.tsx +1 -8
  40. package/reactHooks/player/useAutoSeek.tsx +8 -28
  41. package/reactHooks/player/useSeek.tsx +2 -4
  42. package/reactHooks/player/useTapSeek.tsx +7 -34
  43. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
  44. package/reactHooks/screen/index.ts +2 -0
  45. package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
  46. package/reactHooks/screen/useScreenContext.ts +1 -2
  47. package/reactUtils/index.ts +102 -0
  48. package/analyticsUtils/AnalyticPlayerListener.ts +0 -155
  49. package/analyticsUtils/PlayerAnalyticsManager.ts +0 -90
  50. package/appUtils/focusManager/FocusableEvents.ts +0 -8
  51. package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
  52. package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
  53. package/appUtils/playerManager/DelayedSeekPlayerWrapper.tsx +0 -180
@@ -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,6 +1,7 @@
1
1
  /* global tizen */
2
2
  const isTizen = typeof tizen !== "undefined";
3
3
 
4
+ import { isVizioPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
4
5
  import * as platformKeys from "./keysByPlatform";
5
6
  import { Platform } from "react-native";
6
7
 
@@ -21,6 +22,13 @@ export const ARROW_KEYS = [
21
22
  KEYS.ArrowRight,
22
23
  ];
23
24
 
25
+ /**
26
+ * Platform.OS currently identifies Vizio as LG_TV, therefore we are using isVizioPlatform to identify platform and add keys.
27
+ */
28
+ if (isVizioPlatform()) {
29
+ Object.assign(KEYS, platformKeys.vizio);
30
+ }
31
+
24
32
  /**
25
33
  * In TizenOS we need to register all of the keys that we are going to use.
26
34
  * You need to register using the name Tizen has for the key.
@@ -102,4 +102,14 @@ const tvos = {
102
102
  Menu: { code: "Menu", eventType: "menu" },
103
103
  };
104
104
 
105
- export { lg_tv, samsung_tv, web, tvos, android_tv };
105
+ const vizio = {
106
+ ...samsung_tv,
107
+ Exit: { code: "Exit", keyCode: 27 },
108
+ PageUp: { code: "PageUp", keyCode: 33 },
109
+ PageDown: { code: "PageDown", keyCode: 34 },
110
+ MediaTrackNext: { code: "MediaTrackNext", keyCode: 418 },
111
+ MediaTrackPrevious: { code: "MediaTrackPrevious", keyCode: 419 },
112
+ PrevCh: { code: "PrevCh", keyCode: 500 },
113
+ };
114
+
115
+ export { lg_tv, samsung_tv, web, tvos, android_tv, vizio };
@@ -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",
@@ -3,6 +3,7 @@ import * as R from "ramda";
3
3
  import { subscriber } from "../../functionUtils";
4
4
  import { utilsLogger, createLogger } from "../../logger";
5
5
  import { Player } from "./player";
6
+ import { AnalyticsTracker } from "../../analyticsUtils/analyticsTracker";
6
7
  import {
7
8
  hasTizenAPIs,
8
9
  subscribeToDeviceNetworkChanges,
@@ -10,6 +11,7 @@ import {
10
11
  } from "@applicaster/quick-brick-core/App/NetworkStatusProvider/utils";
11
12
  import { setUserLanguagePreference } from "./userLanguagePreference";
12
13
  import { PlayerRole } from "./conts";
14
+ import { RNPlayerManager } from "./nativePlayerManager";
13
15
 
14
16
  const { log_error, log_debug, log_warning } = createLogger({
15
17
  category: "General",
@@ -35,10 +37,7 @@ export interface PlayerLifecycleListener {
35
37
  }
36
38
 
37
39
  type PlayersMap = {
38
- [id: string]: {
39
- player: Player;
40
- isInViewport: boolean;
41
- };
40
+ [id: string]: { player: Player; isInViewport: boolean };
42
41
  };
43
42
 
44
43
  export class PlayerManager {
@@ -47,6 +46,7 @@ export class PlayerManager {
47
46
  private playersMap: PlayersMap = {};
48
47
  private manager = subscriber();
49
48
  private castingReceiver: Player;
49
+ private analyticsTracker: AnalyticsTracker;
50
50
  private lifecycleListeners: PlayerLifecycleListener[] = [];
51
51
 
52
52
  public static getInstance() {
@@ -57,7 +57,7 @@ export class PlayerManager {
57
57
  return PlayerManager.instance;
58
58
  }
59
59
 
60
- public getActivePlayerId = (): string | null => {
60
+ public getActivePlayerId = (): String | null => {
61
61
  return this.activePlayerId;
62
62
  };
63
63
 
@@ -102,10 +102,7 @@ export class PlayerManager {
102
102
  }
103
103
 
104
104
  private addPlayer = (id: string, player: Player) => {
105
- this.playersMap[id] = {
106
- player: player,
107
- isInViewport: false,
108
- };
105
+ this.playersMap[id] = { player: player, isInViewport: false };
109
106
  };
110
107
 
111
108
  public isPlayerRegistered = (id: string) => !!this.playersMap[id];
@@ -168,6 +165,10 @@ export class PlayerManager {
168
165
  this.addPlayer(id, playerController);
169
166
 
170
167
  if (playerController.playerRole === PlayerRole.Primary) {
168
+ if (playerController.playerPluginId !== "QuickBrickPlayerPlugin") {
169
+ RNPlayerManager?.["QuickBrickPlayerPlugin"]?.stopBackgroundPlayback?.();
170
+ }
171
+
171
172
  playerController.addListener({
172
173
  id: this.getPlayerListenerId(id),
173
174
  listener: {
@@ -250,6 +251,28 @@ export class PlayerManager {
250
251
  this.castingReceiver = null;
251
252
  }
252
253
 
254
+ /**
255
+ * Handles analytic events, generates a new analytics tracker and transmits events
256
+ * Passes entry data, and playerState to the tracker for additional context
257
+ * The end result is an event formatted and passed to AnalyticsBridge.postEvent
258
+ * When we get the synthetic event we need to pull the data in the e object
259
+ * e contains the return value from native
260
+ */
261
+ public handleAnalyticEvent(event, data = {}, entry: ZappEntry) {
262
+ const playerState = this.getActivePlayer()?.getState();
263
+
264
+ if (!this.analyticsTracker?.handleAnalyticEvent) {
265
+ this.analyticsTracker = new AnalyticsTracker(entry);
266
+ }
267
+
268
+ this.analyticsTracker?.handleAnalyticEvent?.(
269
+ event,
270
+ data,
271
+ entry,
272
+ playerState
273
+ );
274
+ }
275
+
253
276
  /**
254
277
  * Method retrieves the instantiated player instance controller
255
278
  * Instance controller exposes methods like getContentDuration, getContentPosision
@@ -343,9 +366,9 @@ export class PlayerManager {
343
366
  // TODO: Remove
344
367
  if (this.castingReceiver) {
345
368
  this.castingReceiver.rewind(deltaTime);
369
+ } else {
370
+ this.getActivePlayer()?.rewind(deltaTime);
346
371
  }
347
-
348
- this.getActivePlayer()?.rewind(deltaTime);
349
372
  }
350
373
 
351
374
  public forward(deltaTime = null) {
@@ -353,9 +376,9 @@ export class PlayerManager {
353
376
 
354
377
  if (this.castingReceiver) {
355
378
  this.castingReceiver.forward(deltaTime);
379
+ } else {
380
+ this.getActivePlayer()?.forward(deltaTime);
356
381
  }
357
-
358
- this.getActivePlayer()?.forward(deltaTime);
359
382
  }
360
383
 
361
384
  public seeking(time) {
@@ -418,7 +441,7 @@ export class PlayerManager {
418
441
  }
419
442
 
420
443
  // Call method on player just in case
421
- return this.getActivePlayer()?.setLanguage(track);
444
+ return this.getActivePlayer()?.selectTrack(track);
422
445
  }
423
446
 
424
447
  public isRegistered() {
@@ -443,6 +466,7 @@ export class PlayerManager {
443
466
  if (this.castingReceiver) {
444
467
  this.castingReceiver.closeNativePlayer();
445
468
  } else {
469
+ this.getActivePlayer().closeNativePlayer();
446
470
  this.invokeHandler("close");
447
471
  }
448
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
+ };