title: for loop using a raw music array android
body: <p>I am currently trying to create a for loop in which it will play a raw file and when it's done, it will go on to the next sound file in the array. It is currently playing all files at once. Any suggestions as to how i could fix this? I think there might be a problem with the on completion listener, but not sure. Thanks. </p>
  
  <p>my Code:</p>
  
  <pre><code>package com.example.mediatest;
  
  
  
      int[] myMusic = {R.raw.caralarm, R.raw.phonebusysignal, R.raw.phoneoffhook};
  
  
  
      MediaPlayer mp = new MediaPlayer();
  
  
  
     for (int y =0; y&lt;3; y++){
         mp = MediaPlayer.create(this, myMusic[y]);
         mp.start();
         mp.setOnCompletionListener(new OnCompletionListener(){
  
          @Override
          public void onCompletion(MediaPlayer mp) {
              // TODO Auto-generated method stub
  
          }
  
         });
     }
  </code></pre>