From 8c6f40b0a272851110c9c073c75b9e6521e880d0 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 22 Apr 2018 14:41:01 +0200 Subject: [PATCH] Fixed miniplayer position after start Casting magic values to int is not a good idea... --- .../antennapod/core/service/playback/ExoPlayerWrapper.java | 4 ++++ .../de/danoeh/antennapod/core/service/playback/LocalPSMP.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java index b523d9675..3df017e58 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.service.playback; import android.content.Context; import android.net.Uri; import android.view.SurfaceHolder; +import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.ExoPlaybackException; @@ -120,6 +121,9 @@ public class ExoPlayerWrapper implements IPlayer { @Override public int getDuration() { + if (mExoPlayer.getDuration() == C.TIME_UNSET) { + return PlaybackServiceMediaPlayer.INVALID_TIME; + } return (int) mExoPlayer.getDuration(); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java index 7abcc413b..d86c1a632 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java @@ -450,7 +450,8 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer { || playerStatus == PlayerStatus.PAUSED || playerStatus == PlayerStatus.PREPARED) { retVal = mediaPlayer.getDuration(); - } else if (media != null && media.getDuration() > 0) { + } + if (retVal <= 0 && media != null && media.getDuration() > 0) { retVal = media.getDuration(); }