title: Android - Play audio from earpiece
body: <p>I'd like to play audio from a file into the phone's earpiece (or headset of that is connected) using the android <code>MediaPlayer</code>. I tried using the MODE_IN_CALL hack as suggested in this thread - <a href="https://stackoverflow.com/questions/2119060/android-getting-audio-to-play-through-earpiece">Android - Getting audio to play through earpiece</a>  but that did not help. The app also has the <strong>android.permission.MODIFY_AUDIO_SETTINGS</strong> permission, but any call to <code>m_amAudioManager.setSpeakerphoneOn(false);</code> is ignored.</p>
  
  <pre><code>private AudioManager m_amAudioManager;  
  m_amAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);  
  m_amAudioManager.setMode(AudioManager.MODE_IN_CALL); 
  m_amAudioManager.setSpeakerphoneOn(false); 
  </code></pre>
  
  <p>A call to <code>setMode(AudioManager.STREAM_VOICE_CALL);</code> on the <code>MediaPlayer</code> did not help either. </p>
  
  <pre><code>mediaPlayer.reset();
  mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
  mediaPlayer.setDataSource(path);
  mediaPlayer.prepare();
  </code></pre>
  
  <p>Has something changed since android 2.3 to break this code ? I tried the code on Android ICS without any success. Can someone point me in the right direction ? The audio always plays from the speaker phone so far.</p>