2011-07-04 27 views
2

我有一个应用程序需要录制声音并将其存储为文件。当我尝试播放录制的文件时,音量太低。我使用AVAudioPlayerAVAudiorecorder播放n个录音。有人可以帮忙解决这个数量问题吗?我在设备中拥有完整的音量。在iPhone中播放录制文件时音量太低

回答

3

对于大多数这里的解决方案可能是使用与AVAudioSessionCategoryPlayAndRecord类别.defaultToSpeaker选项:

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

但对我来说这个问题竟然是,在我的应用程序不同的成分设置AVAudioSessionModeMeasurement模式的音频会话,无论出于何种原因都会降低输出音量。

0

上面的代码在一些语法更改后工作完美。 我的新代码看起来像这样。

与这一个

AVAudioSession *session = [AVAudioSession sharedInstance]; 
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil]; 
替换这些行代码

AVAudioSession *session = [AVAudioSession sharedInstance]; 
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];