diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-09-11 21:57:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-11 21:57:27 +0200 |
commit | be0399eaec29b3ce52897de09abc8d8920206c6c (patch) | |
tree | f5fb95a3e4b01551642c0ef036007a0401e2b8cb | |
parent | 1dcff228c6c9b8775af616a1cc24b455bd689212 (diff) | |
parent | 93812f1b15d9fa79463f2600f3059af07990850f (diff) | |
download | AntennaPod-be0399eaec29b3ce52897de09abc8d8920206c6c.zip |
Merge pull request #3407 from ByteHamster/fix-widget-no-playbackservice
Fixed widget if playbackservice is not running
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java b/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java index 7938e262d..abb1d0c0b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/PlayerWidgetJobService.java @@ -23,7 +23,9 @@ import com.bumptech.glide.request.RequestOptions; import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.core.R; +import de.danoeh.antennapod.core.feed.MediaType; import de.danoeh.antennapod.core.glide.ApGlideSettings; +import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.receiver.MediaButtonReceiver; import de.danoeh.antennapod.core.receiver.PlayerWidget; import de.danoeh.antennapod.core.service.playback.PlaybackService; @@ -69,9 +71,7 @@ public class PlayerWidgetJobService extends SafeJobIntentService { } synchronized (waitUsingService) { - if (playbackService != null) { - updateViews(); - } + updateViews(); } if (playbackService != null) { @@ -145,9 +145,12 @@ public class PlayerWidgetJobService extends SafeJobIntentService { String progressString; if (playbackService != null) { - progressString = getProgressString(playbackService.getCurrentPosition(), playbackService.getDuration()); + progressString = getProgressString(playbackService.getCurrentPosition(), + playbackService.getDuration(), playbackService.getCurrentPlaybackSpeed()); } else { - progressString = getProgressString(media.getPosition(), media.getDuration()); + float speed = media.getMediaType() == MediaType.VIDEO ? + UserPreferences.getVideoPlaybackSpeed() : UserPreferences.getPlaybackSpeed(); + progressString = getProgressString(media.getPosition(), media.getDuration(), speed); } if (progressString != null) { @@ -211,9 +214,9 @@ public class PlayerWidgetJobService extends SafeJobIntentService { return PendingIntent.getBroadcast(this, 0, startingIntent, 0); } - private String getProgressString(int position, int duration) { + private String getProgressString(int position, int duration, float speed) { if (position > 0 && duration > 0) { - TimeSpeedConverter converter = new TimeSpeedConverter(playbackService.getCurrentPlaybackSpeed()); + TimeSpeedConverter converter = new TimeSpeedConverter(speed); position = converter.convert(position); duration = converter.convert(duration); return Converter.getDurationStringLong(position) + " / " |