Fixed miniplayer position after start

Casting magic values to int is not a good idea...
This commit is contained in:
ByteHamster 2018-04-22 14:41:01 +02:00
parent 6d3fc04f52
commit 8c6f40b0a2
2 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.service.playback;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
@ -120,6 +121,9 @@ public class ExoPlayerWrapper implements IPlayer {
@Override @Override
public int getDuration() { public int getDuration() {
if (mExoPlayer.getDuration() == C.TIME_UNSET) {
return PlaybackServiceMediaPlayer.INVALID_TIME;
}
return (int) mExoPlayer.getDuration(); return (int) mExoPlayer.getDuration();
} }

View File

@ -450,7 +450,8 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|| playerStatus == PlayerStatus.PAUSED || playerStatus == PlayerStatus.PAUSED
|| playerStatus == PlayerStatus.PREPARED) { || playerStatus == PlayerStatus.PREPARED) {
retVal = mediaPlayer.getDuration(); retVal = mediaPlayer.getDuration();
} else if (media != null && media.getDuration() > 0) { }
if (retVal <= 0 && media != null && media.getDuration() > 0) {
retVal = media.getDuration(); retVal = media.getDuration();
} }