Skip to content

Commit 20a4e39

Browse files
committed
fix: async audio progress experience
1 parent 5693df1 commit 20a4e39

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

package/src/components/Attachment/AudioAttachment.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
105105

106106
const handleEnd = async () => {
107107
setAudioFinished(false);
108-
// The order is important here. We need to seek to 0 before pausing the audio.
109-
await seekAudio(0);
110-
if (isExpoCLI) {
111-
await pauseAudio();
112-
}
108+
await pauseAudio();
113109
onPlayPause(item.id, true);
110+
await seekAudio(0);
114111
};
115112

116113
const dragStart = async () => {
@@ -159,7 +156,9 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
159156
onProgress(item.id, positionMillis / (item.duration * 1000));
160157
}
161158
} else {
162-
onProgress(item.id, positionMillis / durationMillis);
159+
if (positionMillis <= durationMillis) {
160+
onProgress(item.id, positionMillis / durationMillis);
161+
}
163162
}
164163
} else {
165164
// Update your UI for the paused state
@@ -185,7 +184,9 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
185184
if (item && item.file && item.file.uri) {
186185
soundRef.current = await Sound.initializeSound(
187186
{ uri: item.file.uri },
188-
{},
187+
{
188+
progressUpdateIntervalMillis: 100,
189+
},
189190
onPlaybackStatusUpdate,
190191
);
191192
}

package/src/components/ProgressControl/WaveProgressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const styles = StyleSheet.create({
191191
borderRadius: 5,
192192
borderWidth: 0.2,
193193
elevation: 6,
194-
height: 25,
194+
height: 28,
195195
shadowOffset: {
196196
height: 3,
197197
width: 0,

0 commit comments

Comments
 (0)