0

I'm coding an app and I need to not interrupt any music the user is playing while the app is recording through the mic.

However, if I use kAudioSessionProperty_OverrideAudioRoute with kAudioSessionOverrideAudioRoute_Speaker for my audio session properties, audio is re-routed to the external speaker even if the headphones are plugged in. If I use kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, background music is not permitted to play even if I'm using kAudioSessionProperty_OverrideCategoryMixWithOthers.

Any ideas?

4

1 回答 1

3

我找到了答案。

不要这样做:

AudioSessionSetProperty( kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof( trueValue ), &trueValue );
AudioSessionSetProperty( kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(trueValue), &trueValue);

相反,首先设置默认扬声器属性:

AudioSessionSetProperty( kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(trueValue), &trueValue);
AudioSessionSetProperty( kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof( trueValue ), &trueValue );

设置默认路径覆盖似乎会被吹走,允许与其他应用程序混合。所以只需设置允许与其他应用程序混合。

于 2012-11-28T21:29:43.437 回答