title: How to check if an audio is playing with Android MediaPlayer?
body: <p>In a situation where I have a listview that in each list item when clicking is an audio and is played when clicked on the desired item.</p>
  
  <p>When you click on multiple items, the audio blends.</p>
  
  <p>I would like to know how I can click on an item and play and if I want another item, when clicking it the previous audio stops and the audio of the clicaco item starts.</p>
  
  <p>I tried to use the code below, but audios do not stop when I click on another item.</p>
  
  <pre><code>@Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  mediaPlayer = MediaPlayer.create(MainActivity.this, caminhoAudio[position]);
  
                  if ( !(mediaPlayer.isPlaying()) )
                  {
                      tocarSom();
                  }
  
              }
              });
  
  
      }
  
      public void tocarSom() {
  
              if (mediaPlayer != null)
              {
              mediaPlayer.start();
              }
  
  
              // LIBERAR MEMÓRIA
              mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                  public void onCompletion(MediaPlayer mediaPlayer) {
                      mediaPlayer.release();
  
                  };
              });
  
          }
  </code></pre>
  
  <p>Thank You!!!</p>