zmxv / react-native-sound

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

React native sound mutes user music (Spotify, deezer, etc.) #763

Open GaylordP opened 2 years ago

GaylordP commented 2 years ago

Hello :)

Thanks you for your library and sorry for my bad english, I'm french

With react-native-background-timer (2.4.1) and react-native-sound (0.11.1), I play a sound after countdown.

import Sound from 'react-native-sound'
...
Sound.setCategory('Playback')
const soundEnd = new Sound('training.mp3', Sound.MAIN_BUNDLE)

...

const playBackgroundTimer = useCallback(
  (timeInSeconds) => {
    const timeoutId = BackgroundTimer.setTimeout(() => {
      soundEnd.play(() => {})
    }, (1000 * timeInSeconds) - 5000)

    return timeoutId
  },
  []
)

The countdown countdown sound (just a five second beep) permanently mutes the user's music (Deezer, Spotify, etc.).

Ideally, I would like the user's music to drop in volume, and if not possible for it to continue after the countdown.

Do you have a solution ?

andkom commented 2 years ago

See #762

ucheNkadiCode commented 2 years ago

Check out the solution in #788, I layed out the steps of how I solved it with the OP's help