zmxv / react-native-sound

React Native module for playing sound clips

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setCategory() mixWithOthers boolean does not work

kyrstencarlson opened this issue · comments

🪲 Description

The mix with others option on setCategory('Playback', true) does not work. It does not at all mix with sounds and causes all music playing in background (like spotify, apple music, etc) to completely stop when opening the app or the sounds from inside the app begin to play.

🪲 What is the observed behavior?

see above

🪲 What is the expected behavior?

sound plays over anything else playing, ie. mixing with others

🪲 Please post your code:

Sound.setCategory('Playback', true);
Sound.setActive(true);
Sound.setMode('Default');

const finalBeep = new Sound('beep_single.mp3', Sound.MAIN_BUNDLE, error => {
    if (error) {
        return;
    }
});

//play function takes a boolean if the user marked sound being ON to return the sound being played.
play(finalBeep, context.isSoundOn);

💡 Does the problem have a test case?

💡 Possible solution

💡 Is there a workaround?

💡 If the bug is confirmed, would you be willing to create a pull request?

Is your issue with...

  • iOS
  • Android
  • Windows

Are you using...

  • React Native CLI (e.g. react-native run-android)
  • Expo
  • Other: (please specify)

Which versions are you using?

  • React Native Sound: 0.11.2
  • React Native: 0.69
  • iOS: 16.2
  • Android:
  • Windows:

Does the problem occur on...

  • Simulator
  • Device

If your problem is happening on a device, which device?

  • Device: iPhone 14 Pro

I'm facing the same issue (spent like 2 hours trying to find issue in react-native-video to finally realize that problem is not there).
I'd like to add that playing the sound is not necessary to reproduce the issue, what causes the background music to stop is the new Sound(...) call.

Well, this issue seems to be a duplicate of this one, and the workaround provided there does work for me.
One thing I noticed is that it's important to call Sound.setCategory('Playback', true); BEFORE new Sound(...). It was not the case for my app, and so I thought that the workaround didn't work.