Calling prepare() after stop() on MediaPlayer throws IllegalStateException

176 views Asked by At

According to the state machine diagram, the following code should be fine (after properly initializing the MediaPlayer instance):

        mediaPlayer.prepare();
        mediaPlayer.stop();
        mediaPlayer.prepare();

But it results in an IllegalStateException on the last call to prepare(). Why?

Note: I realize these three lines of code in isolation are useless, but it illustrates the problem I am having.

1

There are 1 answers

3
Marcos Vasconcelos On

Probably cause you didnt call start() before?

A MediaPlayer when ready will not start automatically, you must call start() so it can play it content.