For some reason when I return from multitasking to the app , the click sound that I have programmed in, plays. It doesn’t play the sound if the function was never called while the user was using the app.
So for example if the user used the app without ever triggering the sound it won’t play when returning from the multitasking screen. However , if the user has triggered the sound once or more than once the sound will play that many times on return.
This behavior can also be noticed when pulling down the notification bar or when a pop up notification appears for low battery.
Code :
async clickSound() {
const soundObject = new Expo.Audio.Sound();
try {
await soundObject.loadAsync(loadedClickSound);
await soundObject.playAsync(loadedClickSound);
} catch (error) {
}
}
Things I have tried :
-
Adding soundObject.unloadAsync() in componentWillUnmount
-
The same thing but right after the sound plays. Although this just causes the sound not to play at all.
Note: I only have an IOS device not sure if the issue can be recreated on android