diff options
Diffstat (limited to 'src/de/danoeh/antennapod/service')
-rw-r--r-- | src/de/danoeh/antennapod/service/PlaybackService.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 6c7619476..afd8de68f 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -82,6 +82,7 @@ public class PlaybackService extends Service { public static final String ACTION_PLAYER_NOTIFICATION = "action.de.danoeh.antennapod.service.playerNotification"; public static final String EXTRA_NOTIFICATION_CODE = "extra.de.danoeh.antennapod.service.notificationCode"; public static final String EXTRA_NOTIFICATION_TYPE = "extra.de.danoeh.antennapod.service.notificationType"; + public static final String EXTRA_PLAYBACK_SPEED = "extra.de.danoeh.antennapod.service.playbackSpeed"; /** * If the PlaybackService receives this action, it will stop playback and @@ -372,10 +373,17 @@ public class PlaybackService extends Service { if (AppConfig.DEBUG) Log.d(TAG, "OnStartCommand called"); int keycode = intent.getIntExtra(MediaButtonReceiver.EXTRA_KEYCODE, -1); + float playbackSpeed = intent.getFloatExtra(EXTRA_PLAYBACK_SPEED, -1); if (keycode != -1) { if (AppConfig.DEBUG) Log.d(TAG, "Received media button event"); handleKeycode(keycode); + } else if (playbackSpeed > 0) { + if (media == null) { + stopSelf(); + } else { + setSpeed(playbackSpeed); + } } else { Playable playable = intent.getParcelableExtra(EXTRA_PLAYABLE); @@ -422,6 +430,7 @@ public class PlaybackService extends Service { stopSelf(); } } + return Service.START_NOT_STICKY; } @@ -979,6 +988,7 @@ public class PlaybackService extends Service { Log.d(TAG, "Resuming/Starting playback"); writePlaybackPreferences(); + setSpeed(UserPreferences.getPlaybackSpeed()); player.start(); if (status != PlayerStatus.PAUSED) { player.seekTo(media.getPosition()); @@ -1537,11 +1547,11 @@ public class PlaybackService extends Service { return false; } - public void setSpeed(double speed) { + public void setSpeed(float speed) { if (media != null && media.getMediaType() == MediaType.AUDIO) { AudioPlayer audioPlayer = (AudioPlayer) player; if (audioPlayer.canSetSpeed()) { - audioPlayer.setPlaybackSpeed((float) speed); + audioPlayer.setPlaybackSpeed(speed); if (AppConfig.DEBUG) Log.d(TAG, "Playback speed was set to " + speed); sendNotificationBroadcast( @@ -1550,11 +1560,11 @@ public class PlaybackService extends Service { } } - public void setPitch(double pitch) { + public void setPitch(float pitch) { if (media != null && media.getMediaType() == MediaType.AUDIO) { AudioPlayer audioPlayer = (AudioPlayer) player; if (audioPlayer.canSetPitch()) { - audioPlayer.setPlaybackPitch((float) pitch); + audioPlayer.setPlaybackPitch(pitch); } } } |