title: How to stop MediaPlayer stream and then restart it? Android
body: <p>I am making a simple app to play a online radio stream. I know how to set up the stream. Here is my code so far. It sets up the stream and plays it fine. But if I hit stop, I cannot get it to start again. Am I missing something obvious?</p>
  
  <pre><code>final MediaPlayer mediaPlayer = new MediaPlayer();
      mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
      try {
          mediaPlayer.setDataSource(url);
      } catch (IllegalArgumentException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (SecurityException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IllegalStateException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      try {
          mediaPlayer.prepare();
      } catch (IllegalStateException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } // might take long! (for buffering, etc)
  
     streamButton = (ToggleButton) findViewById(R.id.playstopstream);
  
     streamButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  
      @Override
      public void onCheckedChanged(CompoundButton arg0, final boolean isChecked) {
          // TODO Auto-generated method stub
           new Thread(new Runnable() {
  
              @Override
              public void run() {
                  // TODO Auto-generated method stub
                  if(isChecked)
                  {
  
  
                      mediaPlayer.start();
  
                  }
                  else
                  {
                      mediaPlayer.stop();
                      mediaPlayer.reset();
  
  
  
                  }
              }
  </code></pre>