Repository: zmxv/react-native-sound

Issue #652: Ducking Others Audios
Created: 2020-02-24T20:25:36Z
🪲 Description
Ducking (lower the volume from) others audios in background.
🪲 What is the observed behavior?
The audio from other app (like Spotify)  and from react-native-sound(RNS) are mix together, however there are at the same volume :

The user put some music, from Spotify for example.
The user come to my app and launch the game ( about every 3 minute a name is called).
When a name is called from RNS audio, the Spotify's audio and RNS audio are at the same volume.

🪲 What is the expected behavior?

The user put some music, from Spotify for example.
The user come to my app and launch the game ( about every 3 minute a name is called).
When a name is called from RNS audio, the Spotify's audio would be ducked.
At the end of RNS audio, the Spotify's audio will be set at his normal volume.

🪲 Please post your code:
// The Sounds object 
    let whoosh;

// Import the react-native-sound module
    let Sound = require('react-native-sound');

// Enable playback in silence mode, mixWithOthers and background
    Sound.setCategory('Playback', true);
    Sound.setMode('SpokenAudio');

// What is called every 3 minute
    var whoosh = new Sound('./audios/actions/saxo.mp3', Sound.MAIN_BUNDLE, (error) => {
      if (error) {
        console.log('failed to load the sound', error);
        return;
      }
      // Play the sound with an onEnd callback
      whoosh.play((success) => {
        if (success) {
          console.log('successfully finished playing, go for another lauch TimeOut');
          this._launchTimeOut();
        } else {
          console.log('playback failed due to audio decoding errors');
        }
      });
    });
💡 Does the problem have a test case?

Create a RNS object
Put some music, from Spotify for example
Launch RNS audio
Confirm that duck is not working

💡 Possible solution
Maybe it would be possible that I didn't use the right mode when I called
Sound.setMode()
But I tried every mode they have :
//"Default", "VoiceChat", "VideoChat", "GameChat", "VideoRecording", "Measurement", "MoviePlayback", "SpokenAudio".
Or Maybe it would be possible that it was for this function
Sound.setCategory()
But I also tried every mode they have :
//"Ambient", "SoloAmbient", "Playback", "Record", "PlayAndRecord", "AudioProcessing", "MultiRoute".
💡 Is there a workaround?
I tried a lot of things but I completly stuck. If anyone succeeds to duck other audios in background it would be perfect.
💡 If the bug is confirmed, would you be willing to create a pull request?
Yes
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.0"
React Native: "~0.61.4"
iOS: 12.1.4
Android: 10
Windows: X

Does the problem occur on...

 Simulator
 Device

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

Device: Iphone 7

Duplicate issue #644: How do I implement ducking on Android ?
Created: 2020-02-11T06:18:17Z
Actually on background music is playing and when react-native-sound play it should lower the other sound. How to achieve this?

Closing comment (2020-03-06T21:41:27Z): Similar to #652