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);
謝謝!