Fixed widget if playbackservice is not running
This commit is contained in:
parent
ada0101b07
commit
93812f1b15
|
@ -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,10 +71,8 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
|
|||
}
|
||||
|
||||
synchronized (waitUsingService) {
|
||||
if (playbackService != null) {
|
||||
updateViews();
|
||||
}
|
||||
}
|
||||
|
||||
if (playbackService != null) {
|
||||
try {
|
||||
|
@ -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) + " / "
|
||||
|
|
Loading…
Reference in New Issue