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