@draftbit/core 54.1.1-ab9b11.2 → 54.1.2
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.
- package/lib/typescript/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js +5 -11
- package/lib/typescript/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +1 -1
- package/lib/typescript/src/components/MediaPlayer/MediaPlaybackWrapper.js +1 -1
- package/lib/typescript/src/components/MediaPlayer/MediaPlaybackWrapper.js.map +1 -1
- package/lib/typescript/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +14 -25
- package/lib/typescript/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.tsx +5 -12
- package/src/components/MediaPlayer/MediaPlaybackWrapper.tsx +1 -1
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.tsx +13 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "54.1.
|
|
3
|
+
"version": "54.1.2",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "./src/index.tsx",
|
|
6
6
|
"react-native": "./src/index.tsx",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"homepage": "https://github.com/draftbit/react-native-jigsaw#readme",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
45
|
-
"@draftbit/theme": "
|
|
45
|
+
"@draftbit/theme": "54.1.2",
|
|
46
46
|
"@emotion/react": "^11.13.5",
|
|
47
47
|
"@emotion/styled": "^11.13.5",
|
|
48
48
|
"@expo/vector-icons": "^15.0.3",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
],
|
|
124
124
|
"testEnvironment": "node"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "8227f7bcc8f5ff9955379247bdfdbbc0c38c0ef4"
|
|
127
127
|
}
|
|
@@ -4,7 +4,6 @@ import { HeadlessAudioPlayerProps } from "./AudioPlayerCommon";
|
|
|
4
4
|
import {
|
|
5
5
|
normalizeBase64Source,
|
|
6
6
|
useSourceDeepCompareMemoize,
|
|
7
|
-
useSourceDeepCompareEffect,
|
|
8
7
|
} from "../MediaPlayerCommon";
|
|
9
8
|
import type { MediaPlayerRef, MediaPlayerStatus } from "../MediaPlayerCommon";
|
|
10
9
|
import MediaPlaybackWrapper from "../MediaPlaybackWrapper";
|
|
@@ -60,6 +59,10 @@ const HeadlessAudioPlayer = React.forwardRef<
|
|
|
60
59
|
}, []);
|
|
61
60
|
|
|
62
61
|
React.useEffect(() => {
|
|
62
|
+
// 'useAudioPlayer' builds a new player whenever the source changes, so the
|
|
63
|
+
// mirrored playing state has to be resynced
|
|
64
|
+
setIsPlaying(player.playing);
|
|
65
|
+
|
|
63
66
|
const subscription = player.addListener(
|
|
64
67
|
"playbackStatusUpdate",
|
|
65
68
|
(status) => {
|
|
@@ -75,17 +78,7 @@ const HeadlessAudioPlayer = React.forwardRef<
|
|
|
75
78
|
}
|
|
76
79
|
);
|
|
77
80
|
return () => subscription.remove();
|
|
78
|
-
}, []);
|
|
79
|
-
|
|
80
|
-
// Replace source when it changes (deep comparison on URI to avoid unnecessary reloads)
|
|
81
|
-
const isFirstSourceRender = React.useRef(true);
|
|
82
|
-
useSourceDeepCompareEffect(() => {
|
|
83
|
-
if (isFirstSourceRender.current) {
|
|
84
|
-
isFirstSourceRender.current = false;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
player.replace(normalizeBase64Source(source, "audio") as any);
|
|
88
|
-
}, [source]);
|
|
81
|
+
}, [player]);
|
|
89
82
|
|
|
90
83
|
const updateAudioMode = React.useCallback(async () => {
|
|
91
84
|
try {
|
|
@@ -13,14 +13,12 @@ import {
|
|
|
13
13
|
useVideoPlayer,
|
|
14
14
|
TimeUpdateEventPayload,
|
|
15
15
|
VideoPlayer as VideoPlayerType,
|
|
16
|
-
VideoSource,
|
|
17
16
|
} from "expo-video";
|
|
18
17
|
import { setAudioModeAsync } from "expo-audio";
|
|
19
18
|
import { extractSizeStyles } from "../../../utilities";
|
|
20
19
|
import MediaPlaybackWrapper from "../MediaPlaybackWrapper";
|
|
21
20
|
import {
|
|
22
21
|
normalizeBase64Source,
|
|
23
|
-
useSourceDeepCompareEffect,
|
|
24
22
|
useSourceDeepCompareMemoize,
|
|
25
23
|
} from "../MediaPlayerCommon";
|
|
26
24
|
import type {
|
|
@@ -87,6 +85,7 @@ const VideoPlayer = React.forwardRef<VideoPlayerRef, VideoPlayerProps>(
|
|
|
87
85
|
p.muted = isMuted;
|
|
88
86
|
p.volume = volume;
|
|
89
87
|
p.playbackRate = rate;
|
|
88
|
+
p.timeUpdateEventInterval = 0.5;
|
|
90
89
|
});
|
|
91
90
|
|
|
92
91
|
const videoPlayerRef = React.useRef<VideoPlayerComponent>(null);
|
|
@@ -125,6 +124,11 @@ const VideoPlayer = React.forwardRef<VideoPlayerRef, VideoPlayerProps>(
|
|
|
125
124
|
const hasAppliedInitialState = React.useRef(false);
|
|
126
125
|
|
|
127
126
|
React.useEffect(() => {
|
|
127
|
+
// 'useVideoPlayer' builds a new player whenever the source changes, so the
|
|
128
|
+
// initial state has to be applied again
|
|
129
|
+
hasAppliedInitialState.current = false;
|
|
130
|
+
setIsPlaying(player.playing);
|
|
131
|
+
|
|
128
132
|
const timeUpdateSub = player.addListener("timeUpdate", (status) => {
|
|
129
133
|
onPlaybackStatusUpdateProp?.(mapToMediaPlayerStatus(status, player));
|
|
130
134
|
});
|
|
@@ -171,18 +175,7 @@ const VideoPlayer = React.forwardRef<VideoPlayerRef, VideoPlayerProps>(
|
|
|
171
175
|
playToEndSub.remove();
|
|
172
176
|
statusChangeSub.remove();
|
|
173
177
|
};
|
|
174
|
-
}, []);
|
|
175
|
-
|
|
176
|
-
// Replace video source when it changes (deep comparison on URI to avoid unnecessary reloads)
|
|
177
|
-
const isFirstSourceRender = React.useRef(true);
|
|
178
|
-
useSourceDeepCompareEffect(() => {
|
|
179
|
-
if (isFirstSourceRender.current) {
|
|
180
|
-
isFirstSourceRender.current = false;
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
hasAppliedInitialState.current = false;
|
|
184
|
-
player.replace(normalizeBase64Source(source, "video") as VideoSource);
|
|
185
|
-
}, [source]);
|
|
178
|
+
}, [player]);
|
|
186
179
|
|
|
187
180
|
let mappedVideoContentFit: VideoContentFit;
|
|
188
181
|
switch (resizeMode) {
|
|
@@ -232,16 +225,13 @@ const VideoPlayer = React.forwardRef<VideoPlayerRef, VideoPlayerProps>(
|
|
|
232
225
|
ref,
|
|
233
226
|
() => ({
|
|
234
227
|
toggleFullscreen,
|
|
235
|
-
seekToPosition:
|
|
236
|
-
mediaPlaybackWrapperRef.current?.seekToPosition
|
|
237
|
-
togglePlayback:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
play: mediaPlaybackWrapperRef.current?.play || (() => {}),
|
|
228
|
+
seekToPosition: (positionMillis: number) =>
|
|
229
|
+
mediaPlaybackWrapperRef.current?.seekToPosition(positionMillis),
|
|
230
|
+
togglePlayback: () => mediaPlaybackWrapperRef.current?.togglePlayback(),
|
|
231
|
+
pause: () => mediaPlaybackWrapperRef.current?.pause(),
|
|
232
|
+
play: () => mediaPlaybackWrapperRef.current?.play(),
|
|
241
233
|
}),
|
|
242
|
-
|
|
243
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
|
-
[toggleFullscreen, isPlaying]
|
|
234
|
+
[toggleFullscreen]
|
|
245
235
|
);
|
|
246
236
|
|
|
247
237
|
return (
|