开发者

iPhone PlayAndRecord silences all system audio?

In my iPhone app I am trying to record audio and play iPod music at the same time, so I set the audio session category to kAudioSessionCategory_PlayAndRecord. But when I set this, all system audio (including vibrate) doesn't work anymore, although t开发者_开发技巧he iPod audio still does work. Does anyone know if this is a bug in the SDK or something, or how to get around it? Please help!

Thanks in advance!


Looking at the documentation for kAudioSessionOverrideAudioRoute tells us that the default for the category PlayAndRecord is to route the audio to the receiver (the speaker used when you're talking on the phone). Is it possible that all the audio is being routed to that and you just can't hear without putting your ear there?

If you want to change where the audio is going you need to call AudioSessionSetProperty, and pass it the constant specifying where you want the audio to go. These constants are

kAudioSessionOverrideAudioRoute_None, which specifies that you wish the audio to be routed to the receiver (as it is now), or

kAudioSessionOverrideAudioRoute_Speaker, which specifies that audio should be routed to the speaker at the bottom of the phone

UInt32 routeVar = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(routeVar), &routeVar);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜