5

Now i'd like to list available audio output route in my iPhone app, something like this:

http://www.blogcdn.com/www.tuaw.com/media/2008/09/cb(iphone-101_-switch-between-audio-outputs-for-your-voicemail)1729387198273.jpg

i know that i can use audioRouteChangeListener of audio session to get route change info, but this method only can get the message after my app launch, so if headset and bluetooth both are connected before my app run, how can i get these routes' messages, any tips are appreciated.

Thanks.

Asnor
  • 113
  • 1
  • 3
  • 8

2 Answers2

2

I got something working using MPVolumeView . This component has a button that lets you choose the output audio route, like in the Music App.

If you want you can hide the slider (and have only the button) using:

self.myMPVolumeView.showsVolumeSlider = NO;

At the moment I cannot find a way to obtain the output destinations and input sources programmatically as I pointed out in this question List available output audio target AVAudioSession

Community
  • 1
  • 1
lucianoenrico
  • 1,486
  • 1
  • 13
  • 21
0

there are only 5 audio input routes (iOS5+):

kAudioSessionInputRoute_LineIn;
kAudioSessionInputRoute_BuiltInMic;
kAudioSessionInputRoute_HeadsetMic;
kAudioSessionInputRoute_BluetoothHFP;
kAudioSessionInputRoute_USBAudio;

and there are 9 audio output routes (iOS5+):

kAudioSessionOutputRoute_LineOut;
kAudioSessionOutputRoute_Headphones;
kAudioSessionOutputRoute_BluetoothHFP;
kAudioSessionOutputRoute_BluetoothA2DP;
kAudioSessionOutputRoute_BuiltInReceiver;
kAudioSessionOutputRoute_BuiltInSpeaker;
kAudioSessionOutputRoute_USBAudio;
kAudioSessionOutputRoute_HDMI;
kAudioSessionOutputRoute_AirPlay;

find more information here how you can check the availability of them in your application.

holex
  • 23,961
  • 7
  • 62
  • 76
  • This doesn't tell you how to get the list of outputs that are currently available to the user. – TALE Nov 07 '19 at 15:05
  • a property has become available for devs later in history (iOS7+), and it called [`availableInputs`](https://developer.apple.com/documentation/avfoundation/avaudiosession/1616557-availableinputs), which helps you to list the potential inputs of the device in runtime. – holex Nov 11 '19 at 08:13
  • Any updates on how to get the list of **outputs**, not inputs? – demon9733 Mar 02 '20 at 12:43