如果用手机扬声器播放声音,同时开启录制功能,扬声器音量会变小,解决有两种;
1、UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,
sizeof(audioRouteOverride),&audioRouteOverride);可惜这个方法在iOS7.0以后变成deprecated!
2、[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:&error];这个方法6.0以后可用;