diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 56bdce375..421aae85e 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -1553,6 +1553,16 @@ public class PlaybackService extends Service { } } } + + public double getCurrentPlaybackSpeed() { + if (media.getMediaType() == MediaType.AUDIO && player instanceof AudioPlayer) { + AudioPlayer audioPlayer = (AudioPlayer) player; + if (audioPlayer.canSetSpeed()) { + return audioPlayer.getCurrentSpeedMultiplier(); + } + } + return -1; + } /** * call getDuration() on mediaplayer or return INVALID_TIME if player is in diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java index cebb11cf0..b80cb54bc 100644 --- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java @@ -654,6 +654,24 @@ public abstract class PlaybackController { return false; } + public boolean canSetPlaybackSpeed() { + return playbackService != null && playbackService.canSetSpeed(); + } + + public void setPlaybackSpeed(double speed) { + if (playbackService != null) { + playbackService.setSpeed(speed); + } + } + + public double getCurrentPlaybackSpeedMultiplier() { + if (canSetPlaybackSpeed()) { + return playbackService.getCurrentPlaybackSpeed(); + } else { + return -1; + } + } + /** * Returns true if PlaybackController can communicate with the playback * service.