zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 749 forks source link

Multiple sound categories #674

Open MaxToyberman opened 4 years ago

MaxToyberman commented 4 years ago

:beetle: Description

I have multiple sounds in my app, some of them should use Playback mode, and some of them Ambient.

:beetle: What have you tried?

creating a new Sound everytime and using setCategory on this sound.

:beetle: Please post your code:

const buildSound = (key, soundAsset) => new Promise((resolve) => {
  const sound = new Sound(soundAsset, (error) => {
    if (error) {
      console.log('failed to load the sound', error);
      return;
    }
    sound.setCategory(category);
    soundMap = { ...soundMap, [key]: sound };
    resolve(soundMap);
  });
});

:bulb: Possible solution

I have a solution which i don't like, reset the category everytime when i finish working with a sound. couln't find better solution. (seCategory is static ) Is your issue with...

Are you using...

Which versions are you using?