I have this function that plays a file using mediaplayer
public boolean playURL(final String playURL, int makeBig, final int ts){
try{
Player.current_url = playURL;
final String hour = Utils.getHourFromUrl(playURL);
final String date = Utils.getDateFromUrl(playURL);
currentPlayingDate = date;
int minutes = ts/60;
String minuteToSet = Utils.appendZeros(String.valueOf(minutes));
final String dateString = hour+":"+minuteToSet;
currentPlayingTime = dateString;
stateHandler.removeCallbacksAndMessages(null);
MainActivity.mediaPlayer.reset();
MainActivity.mediaPlayer.setDataSource(playURL);
MainActivity.mediaPlayer.prepare();
MainActivity.mediaPlayer.seekTo(ts * 1000);
//some more code
}
It works fine, but sometimes, if I pass damaged file to it, and then press some keys, the app crashes with errors in debugger:
Note that if I just wait for it for several seconds, it won't crash and app will continue to work, it crashes only when I press some keys when mediaplayer is struggling to play damaged file.
I'm trying for hours to find solution for this and prevent the app crashing, but I can't. any help at all will be appreciated, thanks!
Edit 1: adding error logcat at the time crash happens: http://pastebin.com/raw/taVyrvqM