From eb943619af3e7fef82151e183561029683b189c9 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 10 Nov 2019 11:30:58 +0100 Subject: [PATCH] do not crash when audio file reports zero length --- .../eu/siacs/conversations/ui/service/AudioPlayer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java index 5e89fca49..67ee87da2 100644 --- a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java +++ b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java @@ -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; }