expo app playing sounds on return from multitasking

#1

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 :

  1. Adding soundObject.unloadAsync() in componentWillUnmount

  2. 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

#2

Hey @amansahil - this sounds like a bug. Would you be able to create a snack that minimally reproduces this problem and open a GH issue here? https://github.com/expo/expo/issues That will really help us in debugging the issue. Thanks so much!

1 Like
#3

Hi, I believe this was reported here as well. Maybe you can provide more info on that thread?

#4

@esamelson

Just opened an issue and created a snack

issue : https://github.com/expo/expo/issues/1490

snack: https://snack.expo.io/B1y4HpwdM

#5

That issue was because the sounds were unhandled and weren’t playing during the initial call. This causes the playAsync to play out of turn when following steps I mentioned are followed.

closed #6

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.