React-native-sound: How do I implement ducking on both Android and iOS?

Created on 23 Nov 2018  路  7Comments  路  Source: zmxv/react-native-sound

How can I duck other audio while the audio file is playing? I found the set/getSystemAudio function in the API wiki page, but those seem to be only for Android. I decided to try those out on my Android device but calling them would crash the application.

Is there a way to duck the audio through react-native-sound or any other method?

question

Most helpful comment

Hey there. How did you implement ducking? I would expect below to work but it's not. Default settings do not duck the sound in IOS. Can you share your settings please?

Sound.setCategory('Playback', true);
Sound.setMode('SpokenAudio');

All 7 comments

Seems like the module is ducking audio on iOS, but not on Android. How can I fix this?

iOS is ducking the audio, but the ducking is not released. All other audio volume is lowered permanently.

Hey there. How did you implement ducking? I would expect below to work but it's not. Default settings do not duck the sound in IOS. Can you share your settings please?

Sound.setCategory('Playback', true);
Sound.setMode('SpokenAudio');

Hey there. How did you implement ducking? I would expect below to work but it's not. Default settings do not duck the sound in IOS. Can you share your settings please?

Sound.setCategory('Playback', true);
Sound.setMode('SpokenAudio');

Hi,
I tried different settings like you wrote but none of them works. All the audios are at the same volume. mixWithOthers maybe works but it not duck the other. It just permits to have all the audio in same time.

Do you find a way to get around and allow duck?
Thx.

Do you find a way to get around and allow duck?
Thx.

Hi. I ended up implementing my own solution using NativeModules. Did not use any 3rd party libs just built-in Apple and Android audio libraries. It's relatively easy with NativeModules if you have some experience in Java and Swift. And you get a strong API with good documentation. Sorry, probably not the answer you're looking for.

Do you find a way to get around and allow duck?
Thx.

Hi. I ended up implementing my own solution using NativeModules. Did not use any 3rd party libs just built-in Apple and Android audio libraries. It's relatively easy with NativeModules if you have some experience in Java and Swift. And you get a strong API with good documentation. Sorry, probably not the answer you're looking for.

Thanks for answering, it still help me
I never touch Swift. Could you send me some code just for duck and background or is it too complicated?

Hey sorry I don't have access to that codebase anymore but I have used below option:

https://developer.apple.com/documentation/avfoundation/avaudiosession/categoryoptions/1616618-duckothers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zakster12 picture zakster12  路  16Comments

adrian621 picture adrian621  路  15Comments

esutton picture esutton  路  19Comments

FatemeKhodayari picture FatemeKhodayari  路  12Comments

badpenguin picture badpenguin  路  21Comments