Android MediaPlayer - switch to next song
===

I want to use MediaPlayer to consecutively play midi files that are being generated by the app.

I can play test3.midi like this:

    mediaPlayer = MediaPlayer.create(this, R.raw.test3);
    mediaPlayer.start();

I read that I should be able to play the next song consecutively with onCompletion()

The problem is that test3.midi does not exist yet, as it is generated on the fly just before the mediaPlayer is executed. The same goes for the file that has to be played after test3, it does not exist yet.

If I load test3 before it exists, the code gives me errors. Is there a way to circumvent this?

Thanks!