1.设置类别,表示该应用同时支持播放和录音
OSStatus error;
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory
);
2.通过音频会话可以强制的设置应用程序使用指定的输出方式,例如:内声道,扬声器,代码如下
UInt32 audioRouteOverride = isNoOpen ?kAudioSessionOverrideAudioRoute_None:kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride);
摘自:http://blog.csdn.net/ysy441088327/article/details/8164120 感谢作者分享