title: error (-38, 0) media player
body: <p>Whenever i am trying to stop the media player in an another activity than i am getting an error:
   E/MediaPlayer: start called in state 64, mPlayer(0xa3baf580)
   E/MediaPlayer: error (-38, 0)</p>
  
  <pre><code>MainActivity:
  </code></pre>
  
  <p>package radiofm.arabelradio;</p>
  
  <pre><code>import android.content.res.Configuration;
  import android.media.AudioManager;
  import android.media.MediaPlayer;
  import android.os.AsyncTask;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarActivity;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.app.ActionBar;
  import android.support.v7.widget.Toolbar;
  import android.os.Bundle;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ImageButton;
  
  import java.io.IOException;
  
  import static android.media.AudioManager.STREAM_MUSIC;
  
  public class MainActivity extends AppCompatActivity {
  
  
      ImageButton id_play;
      MediaPlayer mediaPlayer;
      boolean prepared = false;
      boolean started =false;
      String stream ="http://arabelfm.ice.infomaniak.ch/arabelprodcastfm.mp3";
      //main_page contain arabel_photo player for radio
  
  
  
       private DrawerLayout mDrawerLayout;
      private ActionBarDrawerToggle mToggle;
  
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          /////////////////////////////////////////////////////////////////////////////
          id_play = (ImageButton) findViewById(R.id.id_play);
          id_play.setEnabled(false);
          //id_play.setText("LOADING");
          mediaPlayer = new MediaPlayer();
          mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
          new PlayerTask().execute(stream);
          id_play.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  if (started){
                      started=false;
                      mediaPlayer.stop();
                      id_play.setImageResource(R.drawable.play);
                     // id_play.setText("PLAY");
                  }
                  else {
                      started=true;
                      mediaPlayer.start();
                      id_play.setImageResource(R.drawable.pause);
  
                      //id_play.setText("PAUSE");
                  }
              }
          });
          //main_page contain arabel_photo player for radio//////////////////////////:
  
  
  
  
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
          mToggle=new ActionBarDrawerToggle(this,mDrawerLayout, R.string.open,R.string.close);
          mDrawerLayout.addDrawerListener(mToggle);
          mToggle.syncState();
  
          getSupportActionBar() .setDisplayHomeAsUpEnabled(true);
          getSupportActionBar() .setHomeButtonEnabled(true);
  
  
  
      }
  
  
  
  
  //////////////////////////////////////////////////////////////////////////////////////////////////////////
      class PlayerTask extends AsyncTask&lt;String,Void,Boolean&gt;{
  
          @Override
          protected Boolean doInBackground(String... strings) {
  
              try {
                  mediaPlayer.setDataSource(strings[0] );
                  mediaPlayer.prepare();
                  prepared=true;
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
              return prepared;
          }
  
          @Override
          protected void onPostExecute(Boolean aBoolean) {
              super.onPostExecute(aBoolean);
              id_play.setEnabled(true);
              id_play.setImageResource(R.drawable.play);
  
              // id_play.setText("PLAY");
          }
      }
  
  
      @Override
      protected void onStop () {
          super.onStop();
      }
  
  
          @Override
      protected void onPause() {
          super.onPause();
          if(started){
              mediaPlayer.pause();
          }
      }
  
  
  
      @Override
      protected void onResume() {
          super.onResume();
          if(started){
              mediaPlayer.start();
          }
      }
  
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
          if(prepared){
              mediaPlayer.release();
          }
      }
  /////////////////////////////////////////////////////////////////////////////////////////////////////
      //main_page contain arabel_photo player for radio//////////////////////////:
  
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
  
          if (mToggle.onOptionsItemSelected(item))
          {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>