title: List available output audio target AVAudioSession
body: <p>I need to list the audio outputs available to an iOS application. My question is similar to this one: <a href="https://stackoverflow.com/questions/12264697/how-to-list-available-audio-output-route-on-ios">How to list available audio output route on iOS</a></p>
  
  <p>i tried this code:</p>
  
  <pre><code>NSError *setCategoryError = nil;
  BOOL success = [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback
                                                        error: &amp;setCategoryError];
  
  NSError *activationError = nil;
  [[AVAudioSession sharedInstance] setActive: YES error: &amp;activationError];
  
  …
  NSLog(@"session.currentRoute.outputs count %d", [[[[AVAudioSession sharedInstance] currentRoute] outputs ] count]);
  for (AVAudioSessionPortDescription *portDesc in [[[AVAudioSession sharedInstance] currentRoute] outputs ]) {
      NSLog(@"-----");
      NSLog(@"portDesc UID %@", portDesc.UID);
      NSLog(@"portDesc portName %@", portDesc.portName);
      NSLog(@"portDesc portType %@", portDesc.portType);
      NSLog(@"portDesc channels %@", portDesc.channels);
  }
  </code></pre>
  
  <p>However I always see just one output port (the count is 1), also if I have two (an Airplay and a Built-in speaker).
  If I use the Music application I am able to see both ports and switch between them.
  In my app I only see the one that I have selected.</p>
  
  <p>There is something else that I need to do?</p>
  
  <p>Thank you</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>i tried this code, too:</p>
  
  <pre><code>CFDictionaryRef asCFType = nil;
  UInt32 dataSize = sizeof(asCFType);
  AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &amp;dataSize, &amp;asCFType);
  NSDictionary *audioRoutesDesc = (__bridge NSDictionary *)asCFType;
  NSLog(@"audioRoutesDesc %@", audioRoutesDesc);
  </code></pre>
  
  <p>but the dictionary list just one output destinations. Moreover the input sources array is empty (I have a iPhone 4s)</p>
  
  <p><strong>EDIT2:</strong> </p>
  
  <p>I got something working using MPVolumeView . This component has a button that lets you choose the output audio route, like in the Music App.</p>
  
  <p>If you want you can hide the slider (and have only the button) using:</p>
  
  <pre><code>self.myMPVolumeView.showsVolumeSlider = NO;
  </code></pre>