title: can't stop mp3 file from playing
body: <p>I am new to android programming. I have an mp3 file playing, but won't stop playing when back button is pressed to exit program. I have the MediaPlayer in global, shouldn't it be picked up in back key code? Any help appreciated.</p>
  
  <pre><code>public class JabberWockyActivity extends Activity {
  WebView myWebView;
  Button button1;
  Button button2;
  MediaPlayer mpAudio;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_jabber_wocky);
  
      mpAudio=MediaPlayer.create(this, R.raw.yah3);
      mpAudio.start();
      mpAudio.setLooping(true);       
  
      myWebView = (WebView) findViewById(R.id.webView1);
      myWebView.getSettings().setBuiltInZoomControls(true);
      myWebView.getSettings().setJavaScriptEnabled(true);
  
      myWebView.loadUrl("http://www.jabberwocky.com/carroll/jabber/jabberwocky.html");
  
  
  
  
      button1 = (Button)this.findViewById(R.id.button1);
      button1.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri
                      .parse("https://en.wikipedia.org/wiki/Jabberwocky"));
              startActivity(browserIntent);
          }
      });
  
  
      button2 = (Button)this.findViewById(R.id.button2);
      button2.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri
                  .parse("http://goodvibeblog.com/wp-content/uploads/2010/06/jabberwocky2.jpg"));
          startActivity(browserIntent);
      }
  });
  </code></pre>
  
  <p>}</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.jabber_wocky, menu);
      return true;
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
      // Check if the key event was the Back button and if there's history
      if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; myWebView.canGoBack()) {
          mpAudio.stop();
          myWebView.goBack();
          return true;
  
      }
      // If it wasn't the Back key or there's no web page history, bubble up to the default
      // system behavior (probably exit the activity)
      return super.onKeyDown(keyCode, event);
  }
  </code></pre>
  
  <p>}</p>