How to route audio through Apple device's internal speakers, avoiding headphones?

StackOverflow https://stackoverflow.com/questions/8874707

  •  16-04-2021
  •  | 
  •  

سؤال

I'm using the kAudioSessionPoperty_AudioRoute and setting it to kAudioSessionOverrideAudioRouteSpeaker. I want the output audio to be routed through internal speakers only but when I insert headphones it gets routed through that.

هل كانت مفيدة؟

المحلول

Try this...

UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);

UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top