I want to catch MediaPlayer errors like this:
01-03 21:03:08.797: E/MediaPlayer(9470): error (1, -2147483648)
or this
01-03 20:52:48.859: E/MediaPlayer(8674): error (1, -1004)
Which exception do I need to catch? I tried it with
try {
mp.start();
}
catch (IllegalArgumentException e){Log.d(TAG, "error1");}
catch (IllegalStateException e) {Log.d(TAG, "error2");}
catch (Exception e){Log.d(TAG, "error2");}
But it doesn’t work. Can anyone tell me which exception I have to catch?
You need to implement android.media.MediaPlayer.OnErrorListener in your Fragment or Activity.
When you create your MediaPlayer make sure you call