title: Android MediaPlayer OnPreparedListener
body: <p>I am working on a simple app and using a MediaPlayer to play some background noise in 1 activity. I am reading up on MediaPlayer and am not sure whether or not to implement an OnPreparedListener to trigger the start() method. What are the pros / cons to each approach?</p>
  
  <p>Approach 1:</p>
  
  <pre><code>    mediaPlayer = MediaPlayer.create(context, R.raw.sound);
      mediaPlayer.setLooping(true);
      mediaPlayer.start();
  </code></pre>
  
  <p>Approach 2: </p>
  
  <pre><code>    mediaPlayer = MediaPlayer.create(context, R.raw.sound);
      mediaPlayer.setLooping(true);
      mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
  
          @Override
          public void onPrepared(MediaPlayer mp) {
              mp.start();
  
          }
      });
  </code></pre>