@applicaster/zapp-react-native-ui-components 12.0.0-rc.20 → 12.0.0-rc.22
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.
|
@@ -50,13 +50,17 @@ export const CollapsibleTextContainer = ({
|
|
|
50
50
|
func: (data) => {
|
|
51
51
|
const value = getValue("background_color");
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const valueFromData = pathOr(value, value.split("."), data);
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
valueFromData &&
|
|
57
|
+
(valueFromData.startsWith("#") || valueFromData.startsWith("rgba("))
|
|
58
|
+
) {
|
|
59
|
+
return valueFromData;
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
// return default value
|
|
63
|
+
return additionalStyles.backgroundColor;
|
|
60
64
|
},
|
|
61
65
|
propName: "backgroundColor",
|
|
62
66
|
},
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { setUserCellPlayerMutedPreference } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/userCellPlayerMutedPreference";
|
|
7
7
|
import { loggerLiveImageManager } from "./loggerHelper";
|
|
8
8
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
9
|
+
import { Component } from "react";
|
|
9
10
|
|
|
10
11
|
const { log_debug, log_info, log_error } = loggerLiveImageManager;
|
|
11
12
|
|
|
@@ -36,7 +37,8 @@ type Position = {
|
|
|
36
37
|
type LiveImageProps = {
|
|
37
38
|
player: Player;
|
|
38
39
|
playerId: string;
|
|
39
|
-
setMode
|
|
40
|
+
setMode?: (type: LiveImageType) => void;
|
|
41
|
+
component: Component;
|
|
40
42
|
// TODO: ...primary, powerCell, tvGallery, etc.
|
|
41
43
|
// type: string;
|
|
42
44
|
};
|
|
@@ -164,7 +166,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
164
166
|
|
|
165
167
|
// Fake close event, because we unmount native view
|
|
166
168
|
item.player?.onPlayerClose();
|
|
167
|
-
item.setMode(LiveImageType.Image);
|
|
169
|
+
item.setMode?.(LiveImageType.Image);
|
|
168
170
|
|
|
169
171
|
if (item === this.currentlyPlaying) {
|
|
170
172
|
this.currentlyPlaying = null;
|
|
@@ -191,8 +193,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
this.currentlyPlaying = item;
|
|
194
|
-
|
|
195
|
-
item.setMode(LiveImageType.Video);
|
|
196
|
+
item.setMode?.(LiveImageType.Video);
|
|
196
197
|
|
|
197
198
|
if (item.player.playerState.isReadyToPlay) {
|
|
198
199
|
item.player.play();
|
|
@@ -209,7 +210,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
209
210
|
this.pauseItem(item);
|
|
210
211
|
};
|
|
211
212
|
|
|
212
|
-
public onLiveImageCompleted = (
|
|
213
|
+
public onLiveImageCompleted = (_item: LiveImage) => {
|
|
213
214
|
// TODO: Notify listeners that player has died
|
|
214
215
|
// Do not try look for new playable, otherwise you will restart video finish to play
|
|
215
216
|
};
|
|
@@ -255,7 +256,6 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
255
256
|
|
|
256
257
|
onPrimaryPlayerClosed = () => {
|
|
257
258
|
const playerItem = this.findNextPlayableItem();
|
|
258
|
-
|
|
259
259
|
log_info("onPrimaryPlayerClosed: starting to play visible live-image");
|
|
260
260
|
|
|
261
261
|
this.currentlyPlaying = null;
|
|
@@ -374,7 +374,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
374
374
|
|
|
375
375
|
// TODO: ...Maybe player some other item
|
|
376
376
|
} else {
|
|
377
|
-
item.setMode(LiveImageType.Image);
|
|
377
|
+
item.setMode?.(LiveImageType.Image);
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
// Prevent receiving onEnd event from both `close` and `end` player events
|
|
@@ -390,12 +390,25 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
390
390
|
};
|
|
391
391
|
|
|
392
392
|
onLiveImageError = (item: LiveImage, error: Error) => {
|
|
393
|
-
item.setMode(LiveImageType.Image);
|
|
393
|
+
item.setMode?.(LiveImageType.Image);
|
|
394
394
|
|
|
395
395
|
const currentItem = this.currentlyPlaying;
|
|
396
396
|
|
|
397
|
+
log_debug(
|
|
398
|
+
`onLiveImageError: error: ${error.message}, live-image ${playerInfo(
|
|
399
|
+
item.player
|
|
400
|
+
)}, currentPlayingId: ${
|
|
401
|
+
this.currentlyPlaying?.playerId
|
|
402
|
+
}, primaryPlayerId: ${this.primaryPlayer?.playerId}`
|
|
403
|
+
);
|
|
404
|
+
|
|
397
405
|
if (currentItem === item) {
|
|
398
406
|
this.currentlyPlaying = null;
|
|
407
|
+
|
|
408
|
+
log_debug(
|
|
409
|
+
`onLiveImageError: currentitem: ${currentItem.playerId} was removed`
|
|
410
|
+
);
|
|
411
|
+
|
|
399
412
|
// TODO: ...Maybe player some other item
|
|
400
413
|
}
|
|
401
414
|
|
|
@@ -461,12 +474,13 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
|
|
|
461
474
|
};
|
|
462
475
|
|
|
463
476
|
readonly playerId: string;
|
|
477
|
+
readonly component: Component;
|
|
464
478
|
|
|
465
479
|
constructor(props: LiveImageProps) {
|
|
466
480
|
this.player = props.player;
|
|
467
481
|
this.setMode = props.setMode;
|
|
468
482
|
this.playerId = this.player.playerId;
|
|
469
|
-
|
|
483
|
+
this.component = props.component;
|
|
470
484
|
this.player.addListener({ id: "live-image", listener: this });
|
|
471
485
|
}
|
|
472
486
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// /// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
//
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import * as R from "ramda";
|
|
5
4
|
|
|
6
5
|
import { AppState, AppStateStatus } from "react-native";
|
|
7
6
|
import { TrackedView } from "../TrackedView";
|
|
@@ -9,7 +8,6 @@ import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/l
|
|
|
9
8
|
|
|
10
9
|
import { playerFactory } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/playerFactory";
|
|
11
10
|
|
|
12
|
-
import { BufferAnimation } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/BufferAnimation";
|
|
13
11
|
import {
|
|
14
12
|
isApplePlatform,
|
|
15
13
|
isTV,
|
|
@@ -26,6 +24,7 @@ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerM
|
|
|
26
24
|
import { PlayerRole } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/conts";
|
|
27
25
|
import { getAutoplaySettings } from "./utils";
|
|
28
26
|
import { isString } from "@applicaster/zapp-react-native-utils/stringUtils";
|
|
27
|
+
import { BufferAnimation } from "../PlayerContainer/BufferAnimation";
|
|
29
28
|
|
|
30
29
|
const { log_error } = loggerLiveImageComponent;
|
|
31
30
|
|
|
@@ -55,70 +54,66 @@ const PlayerLiveImageComponent = (props: Props) => {
|
|
|
55
54
|
isTV() ? false : getUserCellPlayerMutedPreference(props.audioMutedByDefault)
|
|
56
55
|
);
|
|
57
56
|
|
|
58
|
-
const [PlayerViewComponent, setPlayerViewComponent] = React.useState(null);
|
|
59
|
-
const Player: any = PlayerViewComponent || BufferAnimation;
|
|
60
|
-
|
|
61
57
|
const ref = React.useRef(null);
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (type ===
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
timeoutRef.current = setTimeout(() => {
|
|
78
|
-
setMode(type);
|
|
79
|
-
}, 1000) as unknown as NodeJS.Timeout;
|
|
80
|
-
} else {
|
|
81
|
-
if (timeoutRef.current) {
|
|
82
|
-
clearTimeout(timeoutRef.current);
|
|
83
|
-
timeoutRef.current = null;
|
|
84
|
-
}
|
|
59
|
+
/**
|
|
60
|
+
* Debounced setMode function.
|
|
61
|
+
*
|
|
62
|
+
* Sets to video with a 1sec delay. Set to image happens immediately and cancels the timeout.
|
|
63
|
+
*
|
|
64
|
+
* @param type video or image
|
|
65
|
+
*/
|
|
66
|
+
const setModeDebounced = React.useCallback((type: LiveImageType) => {
|
|
67
|
+
if (type === LiveImageType.Video) {
|
|
68
|
+
if (type === mode) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
85
71
|
|
|
72
|
+
timeoutRef.current = setTimeout(() => {
|
|
86
73
|
setMode(type);
|
|
74
|
+
}, 1000) as unknown as NodeJS.Timeout;
|
|
75
|
+
} else {
|
|
76
|
+
if (timeoutRef.current) {
|
|
77
|
+
clearTimeout(timeoutRef.current);
|
|
78
|
+
timeoutRef.current = null;
|
|
87
79
|
}
|
|
88
|
-
};
|
|
89
80
|
|
|
81
|
+
setMode(type);
|
|
82
|
+
}
|
|
83
|
+
}, [mode]);
|
|
84
|
+
|
|
85
|
+
const { screenConfig, playerPluginId } = props;
|
|
86
|
+
|
|
87
|
+
const liveImageItem: LiveImage = React.useMemo(() => {
|
|
90
88
|
const playerFactoryItem = playerFactory({
|
|
91
89
|
player: ref,
|
|
92
|
-
listener: props as Record<string, any>,
|
|
93
90
|
playerId,
|
|
94
91
|
autoplay: false,
|
|
95
92
|
entry: item,
|
|
96
|
-
muted,
|
|
97
|
-
playerPluginId:
|
|
98
|
-
screenConfig:
|
|
93
|
+
muted, // Initial muted state, not needed in dependencies
|
|
94
|
+
playerPluginId: playerPluginId,
|
|
95
|
+
screenConfig: screenConfig,
|
|
99
96
|
playerRole: PlayerRole.Cell,
|
|
100
97
|
});
|
|
101
98
|
|
|
102
|
-
const Component = playerFactoryItem?.Component;
|
|
103
|
-
|
|
104
|
-
if (!R.isNil(Component) && Component !== PlayerViewComponent) {
|
|
105
|
-
setPlayerViewComponent(Component);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
99
|
if (playerFactoryItem) {
|
|
109
100
|
return new LiveImage({
|
|
110
101
|
playerId,
|
|
111
102
|
player: playerFactoryItem.controller,
|
|
112
|
-
|
|
103
|
+
component: playerFactoryItem?.Component
|
|
113
104
|
});
|
|
114
105
|
} else {
|
|
115
106
|
throw new Error("Player factory item is null");
|
|
116
107
|
}
|
|
117
|
-
}, [playerId, item
|
|
108
|
+
}, [playerId, item, playerPluginId, screenConfig]);
|
|
109
|
+
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
liveImageItem.setMode = setModeDebounced;
|
|
112
|
+
}, [setModeDebounced, liveImageItem]);
|
|
118
113
|
|
|
119
114
|
const { start, end } = React.useMemo(
|
|
120
115
|
() => getAutoplaySettings(item),
|
|
121
|
-
[item
|
|
116
|
+
[item]
|
|
122
117
|
);
|
|
123
118
|
|
|
124
119
|
const controller = liveImageItem.getPlayer();
|
|
@@ -145,14 +140,14 @@ const PlayerLiveImageComponent = (props: Props) => {
|
|
|
145
140
|
const unregister = LiveImageManager.instance.register(liveImageItem);
|
|
146
141
|
|
|
147
142
|
return () => {
|
|
148
|
-
unregister();
|
|
149
|
-
|
|
150
143
|
if (timeoutRef.current) {
|
|
151
144
|
clearTimeout(timeoutRef.current);
|
|
152
145
|
timeoutRef.current = null;
|
|
153
146
|
}
|
|
147
|
+
|
|
148
|
+
unregister();
|
|
154
149
|
};
|
|
155
|
-
}, [
|
|
150
|
+
}, [item, liveImageItem]);
|
|
156
151
|
|
|
157
152
|
React.useEffect(() => {
|
|
158
153
|
if (!player) {
|
|
@@ -244,7 +239,7 @@ const PlayerLiveImageComponent = (props: Props) => {
|
|
|
244
239
|
|
|
245
240
|
const onPositionUpdated = React.useCallback(
|
|
246
241
|
(data) => {
|
|
247
|
-
const normalizedRect = (rect) => {
|
|
242
|
+
const normalizedRect = (rect: {left: number, right: number, top: number, bottom: number }) => {
|
|
248
243
|
if (!rect) {
|
|
249
244
|
return null;
|
|
250
245
|
}
|
|
@@ -275,7 +270,7 @@ const PlayerLiveImageComponent = (props: Props) => {
|
|
|
275
270
|
LiveImageManager.instance.checkPlayerPosition(liveImageItem);
|
|
276
271
|
}
|
|
277
272
|
},
|
|
278
|
-
[liveImageItem,
|
|
273
|
+
[liveImageItem, dimensions]
|
|
279
274
|
);
|
|
280
275
|
|
|
281
276
|
const platformSpecificProps = isApplePlatform()
|
|
@@ -286,6 +281,7 @@ const PlayerLiveImageComponent = (props: Props) => {
|
|
|
286
281
|
const isVideoMode = mode === LiveImageType.Video;
|
|
287
282
|
const isBackgroundImageVisible = isImageMode || !isReadyToPlay;
|
|
288
283
|
const videoStyles = { ...style, position: "absolute", zIndex: -100 };
|
|
284
|
+
const Player: any = liveImageItem.component || BufferAnimation;
|
|
289
285
|
|
|
290
286
|
return (
|
|
291
287
|
<TrackedView
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.22",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-rc.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-rc.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-rc.22",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.22",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-rc.22",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-rc.22",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|