MediaPlayer array causing null pointer in Android
<p>Can anyone see why I would be getting a NullPointerException with this code? The code is basically to create a MediaPlayer array so that I can loop through it and stop/start all of the mediaplayers at once. They are also linked to seekbars to control volume.</p>

<pre><code>private MediaPlayer[] media;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    //media players

    media[0] = MediaPlayer.create(this, R.raw.drums);



    media[1] = MediaPlayer.create(this, R.raw.bass);


    media[2] = MediaPlayer.create(this, R.raw.synth);


    media[3] = MediaPlayer.create(this, R.raw.snare);


    media[4]  = MediaPlayer.create(this, R.raw.wobble);


    for(int i=0;i&lt;media.length;i++){
         media[i].start();
         media[i].setLooping(true);
         media[i].setVolume(0,0);
    }


   //drums seekbar

    final SeekBar volControl = (SeekBar)findViewById(R.id.volbar);
    volControl.setMax(maxVolume);       
    volControl.setProgress(0);
    volControl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 



        @Override
        public void onStopTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub

        }


        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            // TODO Auto-generated method stub

            media[0].setVolume(arg1, arg1);

        }                       

    });       
</code></pre>
