I know this question has been somewhat dealt with before, but I feel like we could nail this down a bit better.
Here is my present code. The iPhone automatically plays out the speakers (not the earpiece), but when I plug the earphones in nothing happens. I would like it so that it playback is through the speakers, but will route through the headphones if they are plugged in. How can we change this code to properly do this?
// 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);
Thanks!
I did it this way: