title: Media player playing multiple files at the same time
body: <p>I am having a problem where once the user clicks on a sound to play from my ListView, then while that sound is playing they click on another sound, the 2 sounds they clicked play at the same time.</p>
  
  <p>I would like to have the sound that was currently playing, finish, then start the new sound that they most recently clicked.</p>
  
  <p>If someone could help me, that would be much appreciated!</p>
  
  <p>CODE:</p>
  
  <pre><code>ListView BoardList = (ListView) findViewById(R.id.BoardList);
  
      String List[] = {
  
       "Audio1", "Audio2", "Audio3", "Audio4", "Audio5"
           , "Audio6", "Audio7", "Audio8", "Audio9"
             , "Audio10", "Audio11", "Audio12" };
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
              R.layout.listcustomize, R.id.textItem, List);
  
      BoardList.setAdapter(adapter);
  
      BoardList.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                  int position, long id) {
              MediaPlayer mPlayer = null;
              if (position == 0) {
  
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio1);
                  mPlayer.start();
              }
  
              if (position == 1) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio2);
                  mPlayer.start();
  
              }
              if (position == 2) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this, R.raw.Audio3);
                  mPlayer.start();
  
              }
              if (position == 3) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio4);
                  mPlayer.start();
              }
              if (position == 4) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio5);
                  mPlayer.start();
              }
              if (position == 5) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio6);
                  mPlayer.start();
              }
              if (position == 6) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio7);
                  mPlayer.start();
              }
  
              if (position == 7) {
  
  
                  mPlayer = MediaPlayer
                          .create(HodgeMain.this, R.raw.Audio8);
                  mPlayer.start();
              }
              if (position == 8) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio9);
                  mPlayer.start();
              }
              if (position == 9) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio10);
                  mPlayer.start();
              }
              if (position == 10) {
  
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio11);
                  mPlayer.start();
              }
              if (position == 11) {
  
                  mPlayer = MediaPlayer.create(HodgeMain.this,
                          R.raw.Audio12);
                  mPlayer.start();
  
              }
  </code></pre>