@applicaster/zapp-react-native-utils 13.0.0-rc.110 → 13.0.0-rc.112
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.
|
@@ -12,7 +12,7 @@ import { useThrottle } from "../../../functionUtils";
|
|
|
12
12
|
export const usePlayerCurrentTime = (
|
|
13
13
|
listenerId: string,
|
|
14
14
|
playerId?: string
|
|
15
|
-
): number | null => {
|
|
15
|
+
): { currentTime: number | null; cancel: () => void } => {
|
|
16
16
|
const [currentTime, setCurrentTime] = useState<number | null>(null);
|
|
17
17
|
const player: Player = usePlayer(playerId);
|
|
18
18
|
|
|
@@ -20,15 +20,17 @@ export const usePlayerCurrentTime = (
|
|
|
20
20
|
if (player) {
|
|
21
21
|
const newCurrentTime = player.getContentPosition();
|
|
22
22
|
|
|
23
|
-
setCurrentTime(
|
|
24
|
-
prevTime !== newCurrentTime ? newCurrentTime : prevTime
|
|
25
|
-
);
|
|
23
|
+
setCurrentTime(newCurrentTime);
|
|
26
24
|
}
|
|
27
25
|
}, [player]);
|
|
28
26
|
|
|
27
|
+
// We update the current time every ~250ms since player can have rate set to 2x.
|
|
28
|
+
// We update more often than 2x a second to avoid noticiable 'pulsation' in update,
|
|
29
|
+
// since native level also updates the current time every ~250ms,
|
|
30
|
+
// and combined with assorted delays it creates interference pattern.
|
|
29
31
|
const { throttledFunction: throttledUpdate, cancel } = useThrottle(
|
|
30
32
|
updateCurrentTime,
|
|
31
|
-
1000
|
|
33
|
+
1000 / 4
|
|
32
34
|
);
|
|
33
35
|
|
|
34
36
|
useEffect(() => {
|
|
@@ -36,7 +38,9 @@ export const usePlayerCurrentTime = (
|
|
|
36
38
|
throttledUpdate();
|
|
37
39
|
|
|
38
40
|
const listeners = {
|
|
39
|
-
onVideoProgress:
|
|
41
|
+
onVideoProgress: () => {
|
|
42
|
+
setCurrentTime(player.getContentPosition());
|
|
43
|
+
},
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
const id = `${listenerId}_player_current_time`;
|
|
@@ -53,5 +57,5 @@ export const usePlayerCurrentTime = (
|
|
|
53
57
|
}
|
|
54
58
|
}, [player, listenerId, throttledUpdate, cancel]);
|
|
55
59
|
|
|
56
|
-
return currentTime;
|
|
60
|
+
return { currentTime, cancel };
|
|
57
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-rc.
|
|
3
|
+
"version": "13.0.0-rc.112",
|
|
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": "13.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-rc.112",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -39,21 +39,13 @@ function getPlayerConfiguration({ platform }) {
|
|
|
39
39
|
label_tooltip:
|
|
40
40
|
"Disable if you don't want the content to have a right orientation",
|
|
41
41
|
},
|
|
42
|
-
{
|
|
43
|
-
key: "magic_background",
|
|
44
|
-
label: "Enable Magic Background",
|
|
45
|
-
initial_value: false,
|
|
46
|
-
type: "switch",
|
|
47
|
-
label_tooltip:
|
|
48
|
-
"Enable if you want to have adaptive background gradient based on audio background image.",
|
|
49
|
-
},
|
|
50
42
|
{
|
|
51
43
|
key: "audio_player_background_image_query",
|
|
52
44
|
label: "Audio Player Image Query",
|
|
53
45
|
initial_value: "",
|
|
54
46
|
type: "text_input",
|
|
55
47
|
label_tooltip:
|
|
56
|
-
"Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time
|
|
48
|
+
"Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time.",
|
|
57
49
|
},
|
|
58
50
|
{
|
|
59
51
|
key: "audio_player_background_image_default_color",
|