Please provide the following:
- SDK Version: 43.0.0
- Platforms(Android/iOS/web/all): Android
- Add the appropriate “Tag” based on what Expo library you have a question on.
const audios = {
beep: require("../assets/sounds/beepSound.mp3"),
error: require("../assets/sounds/errorSound.mp3"),
repeated: require("../assets/sounds/qrRepeated.mp3"),
};
import * as React from "react";
import { Audio } from "expo-av";
const useSound = () => {
const playSound = React.useCallback(async (soundName) => {
const sound = new Audio.Sound();
try {
await sound.loadAsync(audios[soundName]);
await sound.playAsync(); // Here is the problem
await sleep(1000);
// Your sound is playing!
// Don't forget to unload the sound from memory
// when you are done using the Sound object
await sound.unloadAsync();
} catch (error) {
// An error occurred!
}
}, []);
return { playSound };
};
export default useSound;
I have this code to play a beep sound each time a qr is written with my app, at first it works totally fine, but after playing the sound for aroun 20 times it suddenly stop working, I’m not sure what might be, any idea?