title: iPhone AudioServicesPlaySystemSound: route though headphones?
body: <p>I'm having trouble using AudioServicesPlaySystemSound. Things work great when output goes through the speakers. However, when a user plugs in headphones, there is no output. Is there an easy way to set up some kind of listener so that audio is automatically routed through the headphones when they are plugged in, and otherwise through the speaker? </p>
  
  <p>I'm using the following method to play short, simple AIF sound samples:</p>
  
  <pre><code>-(void)playAif:(NSString *)filename {
      SystemSoundID soundID;
      NSString *path = [[NSBundle mainBundle]
         pathForResource:filename ofType:@"aif"];    
  
      if (path) { // test for path, to guard against crashes
  
      AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path],&amp;soundID);
      AudioServicesPlaySystemSound (soundID);
  
          }
     }
  </code></pre>
  
  <p>I know I must be missing something, some bit of setup that would do this. Any ideas?</p>