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

iOS - Volume going down after recording sound #17

Open
LunatiqueCoder opened this issue Sep 3, 2022 · 2 comments
Open

iOS - Volume going down after recording sound #17

LunatiqueCoder opened this issue Sep 3, 2022 · 2 comments

Comments

@LunatiqueCoder
Copy link

LunatiqueCoder commented Sep 3, 2022

👋 Hello!

Thank you for this great library! Really solved all our issues.

🪲 PROBLEM:

We're using this library along with react-native-video and react-native-sound, and when we record, the volume is going down. This wouldn't be such a great deal, but it gets stuck at a lower level.

⭐️ SOLUTION

Followed this solution https://stackoverflow.com/a/27020411/14056591

Applied it here (line 33 and 38):
https://github.com/xiqi/react-native-live-audio-stream/blob/master/ios/RNLiveAudioStream.m#L33
https://github.com/xiqi/react-native-live-audio-stream/blob/master/ios/RNLiveAudioStream.m#L38

Changed AVAudioSessionCategoryOptionDuckOthers to AVAudioSessionCategoryOptionDefaultToSpeaker

This would be the diff:

--- a/node_modules/react-native-live-audio-stream/ios/RNLiveAudioStream.m
+++ b/node_modules/react-native-live-audio-stream/ios/RNLiveAudioStream.m
     if (@available(iOS 10.0, *)) {
         success = [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord
                                        mode: AVAudioSessionModeVoiceChat
-                                    options: AVAudioSessionCategoryOptionDuckOthers |
+                                    options: AVAudioSessionCategoryOptionDefaultToSpeaker |
                                              AVAudioSessionCategoryOptionAllowBluetooth |
                                              AVAudioSessionCategoryOptionAllowAirPlay
                                       error: &error];
     } else {
-        success = [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions: AVAudioSessionCategoryOptionDuckOthers error: &error];
+        success = [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions: AVAudioSessionCategoryOptionDefaultToSpeaker error: &error];
         success = [audioSession setMode: AVAudioSessionModeVoiceChat error: &error] && success;
     }
     if (!success || error != nil) {

This issue body was partially generated by patch-package.

@LunatiqueCoder LunatiqueCoder changed the title iOS - Volume going down while recording sound iOS - Volume going down after recording sound Sep 4, 2022
@qsdnedzid
Copy link

@criszz77 That alone didn't work for me, I also had to change audioSession mode to AVAudioSessionModeDefault instead of AVAudioSessionModeVoiceChat . But your changes also helped, thank you!

@matthewtoast
Copy link

matthewtoast commented Jun 22, 2023

I'm still seeing the volume reduced when I make all of the above recommended changes. It isn't as bad as before - but it still goes down... maybe to about half of what it was initially. @qsdnedzid did you have to make any further changes other than what you mentioned?

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

No branches or pull requests

3 participants