Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I implement ducking on both Android and iOS? #512

Open
gusoskar opened this issue Nov 23, 2018 · 8 comments
Open

How do I implement ducking on both Android and iOS? #512

gusoskar opened this issue Nov 23, 2018 · 8 comments
Labels

Comments

@gusoskar
Copy link

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?

@gusoskar
Copy link
Author

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

@gusoskar
Copy link
Author

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

@aliustaoglu
Copy link

aliustaoglu commented Mar 6, 2019

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');

@AlexisChup
Copy link

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.

@aliustaoglu
Copy link

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.

@AlexisChup
Copy link

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?

@aliustaoglu
Copy link

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

@EyadAlghamdi
Copy link

I added a new PR to implement ducking (only for iOS so far).
i wrote some instructions to test it out and let me know if there are any issues so i can fix it!
instructions on this issue #652 on how to npm install the new branch to test it out

you can replace react-native-sound branches in your repo back and forth between this main one and the one i made. just make sure to rebuild your ios simulator or device!
cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants