title: How to add two buttons in eclipse one for playing an mp3 file and the other for stopping it
body: <p>I am a newbie in android app development. For now my challenge is to add two buttons in my UI one for playing an mp3 file and the other for stopping it. I am able to do the first successfully and as I try to do the stop one, I see no result. My code is as following:</p>
  
  <pre><code>package ir.polyglotcenter.childrenmostfrequentwords;
  
  import android.app.Activity;
  import android.media.MediaPlayer;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  public class Main extends Activity {
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      Button myButtonOne = (Button) findViewById(R.id.btn_audio);
      myButtonOne.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              MediaPlayer media = MediaPlayer.create(Main.this, R.raw.audio);
              media.start();
  
          }
      });
      //this is to stop the audio flow
      Button myButtonTwo = (Button) findViewById(R.id.btn_stop);
      myButtonTwo.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              MediaPlayer media = MediaPlayer.create(Main.this, R.raw.audio);
              media.stop();
  
          }
      });
  
  }
  }
  </code></pre>