Low recording volume in combination with AVAudioSessionCategoryPlayAndRecord

前端 未结 7 1776
我在风中等你
我在风中等你 2020-12-04 18:30

When I set:

[[AVAudioSession sharedInstance] setCategory:
    AVAudioSessionCategoryPlayAndRecord error:NULL];

…recording and playing works

7条回答
  •  爱一瞬间的悲伤
    2020-12-04 18:48

    I ran into this problem today and it seems this answer is a bit outdated. AudioSessionsSetProperty(...) is now deprecated.

    The following seems to work though, providing full volume through the speakers but automatically routing the audio to headphones if they're plugged in before the app is run:

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error: nil];
    

    And if you'd rather the audio play through the speakers at full volume even if the headphones are plugged in, this works too:

    [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
    

提交回复
热议问题