title: Android : How to handle stop/pause before MediaPlayer is initialised?
body: <p><code>public void onClick(View v)</code> {</p>
  
  <pre><code>switch(v.getId()) {
  
  case R.id.button6:
      Toast.makeText(getApplicationContext(), "Track playing...", Toast.LENGTH_SHORT).show(); 
      player.start(); 
      break;
  
  case R.id.button7:
  
      player.pause(); 
      Toast.makeText(getApplicationContext(), "Track Paused...", Toast.LENGTH_SHORT).show();
      break;
  
  case R.id.button8:
  
      player.stop(); 
      Toast.makeText(getApplicationContext(), "Track Stopped...", Toast.LENGTH_SHORT).show();
      break;
      }
  }
  </code></pre>
  
  <p>I'm trying to handle a case where the user tries to press pause or stop while the music hasn't been played yet, perhaps by popping up another message prompting them. How could I edit my code to do so ?</p>