player.reset();
player.setDataSource(url);
// mPlayer.setDataSource(mFileName);
player.prepareAsync();
player.setOnPreparedListener(
new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
player.start();
}
}
);
This is my mediaplayer bit code. I'm doing the exact thing I should be doing in order to have the state of the media player correctly yet I'm still having the error start called in state 1
can anyone help? Thanks a lot!
I think the problem here is that you need to set the listener before you call player.prepareAsync();
because there is always the possibility (especially if the url points to the disk) that the prepareAsync
call might return before the listener is set.
Change player.start();
to mp.start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With