1
我知道这个问题之前已经有所处理,但我觉得我们可以把这个问题稍微好一点。设置iPhone通过扬声器开始播放,但允许耳机覆盖
这是我现在的代码。 iPhone会自动播放扬声器(不是耳机),但是当我将耳机插入时没有任何反应。我希望它能够通过扬声器进行播放,但如果插入耳机,则会通过耳机传输。我们如何更改此代码以正确执行此操作?
// ORIGINAL CODE
UInt32 category = kAudioSessionCategory_PlayAndRecord;
error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);
if (error) printf("couldn't set audio category!");
// I put this chunk in of code myself. To change the audio to go the speakers (not the earpiece).
// I don't think this is the best way to do this.
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
谢谢!