title: why do i need to click two times to play audio
body: <p>I create a MediaPlayer to play audio with same button. When I click to play the audio first time it is work, after that when i press again to play the same audio I must click another press to play the Audio (2 times). How can i fix this.</p>
  <p><strong>The play Audio method that I use</strong></p>
  <pre><code>    private void playAudio() {
      Button button = findViewById(R.id.play_audio);
      button.setOnClickListener(v -&gt; {
          if (mediaPlayer == null) {
              final AudioManager mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
              final int originalVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
              mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);
              mediaPlayer = MediaPlayer.create(Main.this, R.raw.testa);
              mediaPlayer.start();
              mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
              mediaPlayer.setOnCompletionListener(mp1 -&gt; mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, originalVolume, 0));
          } else {
              mediaPlayer.stop();
              mediaPlayer = null;
          }
      });
  }
  </code></pre>