diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index 67dda01cf..2bcd7a461 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -129,6 +129,7 @@ public class AudioplayerActivity extends MediaplayerInfoActivity { } UserPreferences.setPlaybackSpeed(newSpeed); controller.setPlaybackSpeed(Float.parseFloat(newSpeed)); + onPositionObserverUpdate(); } else { VariableSpeedDialog.showGetPluginDialog(this); } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 154c7c148..3d5c59a4a 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -55,6 +55,7 @@ import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.ShareUtils; import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.Supplier; +import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil; import de.danoeh.antennapod.core.util.playback.ExternalMedia; import de.danoeh.antennapod.core.util.playback.MediaPlayerError; @@ -674,8 +675,11 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements if (controller == null || txtvPosition == null || txtvLength == null) { return; } - int currentPosition = controller.getPosition(); - int duration = controller.getDuration(); + + int currentPosition = TimeSpeedConverter.convert(controller.getPosition()); + int duration = TimeSpeedConverter.convert(controller.getDuration()); + int remainingTime = TimeSpeedConverter.convert( + controller.getDuration() - controller.getPosition()); Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition)); if (currentPosition == PlaybackService.INVALID_TIME || duration == PlaybackService.INVALID_TIME) { @@ -684,7 +688,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements } txtvPosition.setText(Converter.getDurationStringLong(currentPosition)); if (showTimeLeft) { - txtvLength.setText("-" + Converter.getDurationStringLong(duration - currentPosition)); + txtvLength.setText("-" + Converter.getDurationStringLong(remainingTime)); } else { txtvLength.setText(Converter.getDurationStringLong(duration)); } @@ -832,9 +836,13 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements String length; if (showTimeLeft) { - length = "-" + Converter.getDurationStringLong(media.getDuration() - media.getPosition()); + int remainingTime = TimeSpeedConverter.convert( + media.getDuration() - media.getPosition()); + + length = "-" + Converter.getDurationStringLong(remainingTime); } else { - length = Converter.getDurationStringLong(media.getDuration()); + int duration = TimeSpeedConverter.convert(media.getDuration()); + length = Converter.getDurationStringLong(duration); } txtvLength.setText(length); @@ -937,7 +945,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements prog = controller.onSeekBarProgressChanged(seekBar, progress, fromUser, txtvPosition); if (showTimeLeft && prog != 0) { int duration = controller.getDuration(); - String length = "-" + Converter.getDurationStringLong(duration - (int) (prog * duration)); + int timeLeft = TimeSpeedConverter.convert(duration - (int) (prog * duration)); + String length = "-" + Converter.getDurationStringLong(timeLeft); txtvLength.setText(length); } } diff --git a/app/src/main/res/xml/preferences_playback.xml b/app/src/main/res/xml/preferences_playback.xml index 9182df600..8b8efa023 100644 --- a/app/src/main/res/xml/preferences_playback.xml +++ b/app/src/main/res/xml/preferences_playback.xml @@ -46,7 +46,7 @@ app:useStockLayout="true"/> - + + diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 805f0c1b6..c9a18e923 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -73,6 +73,7 @@ public class UserPreferences { private static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss"; private static final String PREF_RESUME_AFTER_CALL = "prefResumeAfterCall"; public static final String PREF_VIDEO_BEHAVIOR = "prefVideoBehavior"; + private static final String PREF_TIME_RESPECTS_SPEED = "prefPlaybackTimeRespectsSpeed"; // Network private static final String PREF_ENQUEUE_DOWNLOADED = "prefEnqueueDownloaded"; @@ -871,4 +872,8 @@ public class UserPreferences { .putString(PREF_BACK_BUTTON_GO_TO_PAGE, tag) .apply(); } + + public static boolean timeRespectsSpeed() { + return prefs.getBoolean(PREF_TIME_RESPECTS_SPEED, false); + } } 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 6dab9a561..773a1f6e1 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 @@ -21,6 +21,7 @@ import de.danoeh.antennapod.core.receiver.PlayerWidget; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.service.playback.PlayerStatus; import de.danoeh.antennapod.core.util.Converter; +import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.core.util.playback.Playable; /** @@ -152,6 +153,8 @@ public class PlayerWidgetJobService extends SafeJobIntentService { private String getProgressString(int position, int duration) { if (position > 0 && duration > 0) { + position = TimeSpeedConverter.convert(position); + duration = TimeSpeedConverter.convert(duration); return Converter.getDurationStringLong(position) + " / " + Converter.getDurationStringLong(duration); } else { diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java b/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java new file mode 100644 index 000000000..5fea8238b --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java @@ -0,0 +1,22 @@ +package de.danoeh.antennapod.core.util; + +import de.danoeh.antennapod.core.preferences.UserPreferences; + +public class TimeSpeedConverter { + private TimeSpeedConverter() { + + } + + /** Convert millisecond according to the current playback speed + * @param time: time to convert + * @return converted time (can be < 0 if time is < 0) + */ + public static int convert(int time) { + boolean timeRespectsSpeed = UserPreferences.timeRespectsSpeed(); + if (time > 0 && timeRespectsSpeed) { + float speed = Float.parseFloat(UserPreferences.getPlaybackSpeed()); + return (int)(time / speed); + } + return time; + } +} diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index 2c70e9435..6191d4491 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -38,6 +38,7 @@ import de.danoeh.antennapod.core.service.playback.PlayerStatus; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.Optional; +import de.danoeh.antennapod.core.util.TimeSpeedConverter; import de.danoeh.antennapod.core.util.playback.Playable.PlayableUtils; import io.reactivex.Maybe; import io.reactivex.MaybeOnSubscribe; @@ -566,8 +567,8 @@ public abstract class PlaybackController { if (fromUser && playbackService != null && media != null) { float prog = progress / ((float) seekBar.getMax()); int duration = media.getDuration(); - txtvPosition.setText(Converter - .getDurationStringLong((int) (prog * duration))); + int position = TimeSpeedConverter.convert((int) (prog * duration)); + txtvPosition.setText(Converter.getDurationStringLong(position)); return prog; } return 0; diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 99759374e..b11f47129 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -377,7 +377,7 @@ Appearance External elements Interruptions - Playback control buttons + Playback control Media player Episode Cleanup Episodes that aren\'t in the queue and aren\'t favorites should be eligible for removal if Auto Download needs space for new episodes @@ -474,6 +474,8 @@ This setting does not apply to authentication errors. Playback Speeds Customize the speeds available for variable speed audio playback + Adjust media info to playback speed + Displayed position and duration are adapted to playback speed Fast Forward Skip Time Customize the number of seconds to jump forward when the fast forward button is clicked Rewind Skip Time