My code looks like this:
MediaPlayer mp = new MediaPlayer();
mp.setDataSource( "http://.../abc.mp3" );
mp.setOnPreparedListener( ... mp.start(); ... );
mp.prepareAsync();
Real code has checked if mp
is prepared before it starts. Mostly it works fine. But sometimes (if weak connection) it still encounters this error:
MediaPlayer: Error (-38,0)
MediaPlayerNative: start called in state 0, mPlayer(0x7424863b40)
So, I decided to catch it:
try {
mp.start();
} catch (IllegalStateException e) {
Toast.makeText(...).show();
} catch (Throwable e) {
Toast.makeText(...).show();
}
But this code does not work, I cannot catch any exception, and that error still displayed in log cat.