title: How to correctly change MediaPlayer audio stream type?
body: <p>I have a simple mp service to play, pause, resume audio. All works fine. 
  But, last night I have decided to add a feature for user to route audio to ear-piece or speaker and have been battling with <code>mp.setAudioStreamType()</code>. </p>
  
  <p>Problem is that I can't change it while service connected and mp created. I don't want to terminate service and/or unbind and rebind as it would require a lot of refactoring
  How do I supposed to change AudioStreamType while playing an audio? </p>
  
  <p>Here is my code:</p>
  
  <p>Player service:</p>
  
  <pre><code>public class PService extends Service {
  
  private MediaPlayer mp = new MediaPlayer();
  public static final String PLAYING_FINISHED_MSG = "1";
  @Override
  public void onCreate() {
      super.onCreate();
  }
  
  @Override
  public void onDestroy() {
      mp.stop();
      mp.release();
  }
  
  private void playSong(String file) {
      try {
          mp.reset();
          mp.setDataSource(file);
          mp.setAudioStreamType(MYAPP.getAudioStreamType());
          mp.prepare();
          mp.start();
  
          mp.setOnCompletionListener(new OnCompletionListener() {
              public void onCompletion(MediaPlayer arg0) {
                  Intent i = new Intent();
                  i.setAction(MDService.PLAYING_FINISHED_MSG);
                  sendBroadcast(i);
              }
          });
  </code></pre>
  
  <p>toggle route button onclick</p>
  
  <pre><code>    currentlyPlayingFile = file;
  currentlyPlayingPhone = phone;
  
  lastDurationBeforePause = mpInterface.getCurrentPosition();
  
   if(MYAPP.getAudioStreamType() == AudioManager.STREAM_MUSIC)
   {
      MYAPP.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
          recording_player_route_button.setImageResource(R.drawable.route_off);                       
    }
    else{
      MYAPP.setAudioStreamType(AudioManager.STREAM_MUSIC);                            
          recording_player_route_button.setImageResource(R.drawable.route_on);
          }           
  
  
  
      try {       
  
          mpInterface.playFile(file); 
          player_seekbar.setProgress(0);
          player_seekbar.setMax(mpInterface.getDuration());
          //seekto last millisecond after switching from/to sepaker
          if(seekTo&gt;0)
          {
              mpInterface.seekTo(seekTo);
          }
          isPauseButtonPressed = false;
          handleSeekBarUpdate.postDelayed(handleSeekBarUpdateJob, 1);
      } catch (RemoteException e) {
          e.printStackTrace();
      }
  </code></pre>