do not crash when audio file reports zero length

This commit is contained in:
Daniel Gultsch 2019-11-10 11:30:58 +01:00
parent 97745bdfbe
commit eb943619af
1 changed files with 6 additions and 2 deletions

View File

@ -346,8 +346,12 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti
return false;
}
final ViewHolder viewHolder = ViewHolder.get(audioPlayer);
viewHolder.progress.setProgress(current * 100 / duration);
viewHolder.runtime.setText(formatTime(current) + " / " + formatTime(duration));
if (duration <= 0) {
viewHolder.progress.setProgress(100);
} else {
viewHolder.progress.setProgress(current * 100 / duration);
}
viewHolder.runtime.setText(String.format("%s / %s", formatTime(current), formatTime(duration)));
return true;
}