zmxv / react-native-sound

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

Cannot play frequent beep in background on Android #727

Open yelnar opened 3 years ago

yelnar commented 3 years ago

:beetle: Sound is not playing in background

:beetle: I am playing beep sound every second.

:beetle:

export const beep = new Sound(
  'beep.mp3',
  Sound.MAIN_BUNDLE,
  (error: string) => {
    if (error) {
      console.log('failed to load the sound', error);
      return;
    }
  },
);

...

React.useEffect(() => {
    const interval = setInterval(() => {
      beep.stop(() => {
        beep.play();
      });
    }, 1000);

    return () => {
      clearInterval(interval);
    };
  }, []);
...

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

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