title: I made an app in which if you click a button an audio will play and if you click twice it will stop but the stop function is working only once
body: <p>Hi I am new to coding and I am making an app in which if you click a button an audio will play and if you double click the button the audio will stop. But the stop function is only working once. How can I solve it. Here's the Code.</p>
  <pre><code>public class MainActivity extends 
  AppCompatActivity {
  private Button rrjk_btn, 
  gdsph_btn, aspamm, stop_btn;
      int counter = 0;
      @Override
      protected void 
  onCreate(Bundle savedInstanceState) {
      
  super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      MediaPlayer mediaPlayer1 = MediaPlayer.create(this, R.raw.radhasoami_rakshak_jeev_ke);
      rrjk_btn = findViewById(R.id.rrjk_btn);
      rrjk_btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              if (counter == 2)
              {
                  mediaPlayer1.pause();
              }
              mediaPlayer1.start();
              counter++;
          }
      });
      //
      MediaPlayer mediaPlayer2 = MediaPlayer.create(MainActivity.this, R.raw.guru_dhara_sheesh_par_haath);
      gdsph_btn = findViewById(R.id.gdsph_btn);
      gdsph_btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              mediaPlayer2.start();
          }
      });
      //
      aspamm = findViewById(R.id.gdsph_btn);
      MediaPlayer mediaPlayer3 = MediaPlayer.create(MainActivity.this, R.raw.ae_satguru_pita_aur_malik_mere);
      aspamm.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              mediaPlayer3.start();
          }
      });
  }
  </code></pre>
  <p>}</p>