Skip to content

Commit 1ee1507

Browse files
committed
refactor: extract audio play logic to a hook
1 parent f852534 commit 1ee1507

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

package/src/components/Attachment/AudioAttachment.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import dayjs from 'dayjs';
55
import duration from 'dayjs/plugin/duration';
66

77
import { useTheme } from '../../contexts';
8+
import { useAudioPlayer } from '../../hooks/useAudioPlayer';
89
import { Audio, Pause, Play } from '../../icons';
910
import {
1011
PlaybackStatus,
@@ -18,7 +19,6 @@ import type { FileUpload } from '../../types/types';
1819
import { getTrimmedAttachmentTitle } from '../../utils/getTrimmedAttachmentTitle';
1920
import { ProgressControl } from '../ProgressControl/ProgressControl';
2021
import { WaveProgressBar } from '../ProgressControl/WaveProgressBar';
21-
import { useAudioPlayer } from '../../hooks/useAudioPlayer';
2222

2323
dayjs.extend(duration);
2424

@@ -51,7 +51,7 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
5151
showSpeedSettings = false,
5252
testID,
5353
} = props;
54-
const { changeAudioSpeed, playAudio, pauseAudio, seekAudio } = useAudioPlayer({ soundRef });
54+
const { changeAudioSpeed, pauseAudio, playAudio, seekAudio } = useAudioPlayer({ soundRef });
5555
const isExpoCLI = !Sound.Player && Sound.initializeSound;
5656

5757
/** This is for Native CLI Apps */

package/src/hooks/useAudioPlayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ export const useAudioPlayer = (props: UseSoundPlayerProps) => {
4444
if (soundRef.current?.setRateAsync) await soundRef.current.setRateAsync(speed);
4545
};
4646

47-
return { playAudio, pauseAudio, seekAudio, changeAudioSpeed };
47+
return { changeAudioSpeed, pauseAudio, playAudio, seekAudio };
4848
};

0 commit comments

Comments
 (0)