Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volume too low on iPhone when playing back the recorded file

I am developing an iOS app wherein I should be able to record a sound, save it to the filesystem and then play it back from the disk. When I try to play the file off the disk, I could barely hear anything. The volume is too low. But I'm pretty sure I'd set the device volume to max. I am using AVAudioRecorder and AVAudioPlayer` for recording and playing.

Could someone please point out what the issue could be?

like image 334
stack2012 Avatar asked Jul 04 '11 05:07

stack2012


2 Answers

For most the solution here will probably be to use the .defaultToSpeaker option with the AVAudioSessionCategoryPlayAndRecord category:

try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: [.defaultToSpeaker])

But for me the issue turned out to be that a different component in my app was setting the AVAudioSessionModeMeasurement mode on the audio session, which for whatever reason reduces the output volume.

like image 186
John Scalo Avatar answered Oct 23 '22 14:10

John Scalo


Set category of AVAudioSession using this method

AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
like image 25
Mehsam Saeed Avatar answered Oct 23 '22 16:10

Mehsam Saeed