Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package/src/hooks/useAudioPlayer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';

import { NativeHandlers, SoundReturnType } from '../native';

Expand All @@ -15,7 +15,7 @@ export const useAudioPlayer = (props: UseSoundPlayerProps) => {

const isExpoCLI = NativeHandlers.SDK === 'stream-chat-expo';

const playAudio = async () => {
const playAudio = useCallback(async () => {
if (isExpoCLI) {
if (soundRef.current?.playAsync) {
await soundRef.current.playAsync();
Expand All @@ -25,9 +25,9 @@ export const useAudioPlayer = (props: UseSoundPlayerProps) => {
soundRef.current.resume();
}
}
};
}, [soundRef.current, isExpoCLI]);

const pauseAudio = async () => {
const pauseAudio = useCallback(async () => {
if (isExpoCLI) {
if (soundRef.current?.pauseAsync) {
await soundRef.current.pauseAsync();
Expand All @@ -37,7 +37,7 @@ export const useAudioPlayer = (props: UseSoundPlayerProps) => {
soundRef.current.pause();
}
}
};
}, [soundRef.current, isExpoCLI]);

const seekAudio = async (currentTime: number) => {
if (isExpoCLI) {
Expand Down