Skip to content

iOS - Volume going down after recording sound #17

Description

@LunatiqueCoder

馃憢 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions