diff options
author | James Falcon <therealfalcon@gmail.com> | 2013-05-06 21:48:18 -0500 |
---|---|---|
committer | James Falcon <therealfalcon@gmail.com> | 2013-05-06 21:48:18 -0500 |
commit | b48c3807fd23df0a6d953ebdabaaf2330bc4f3d3 (patch) | |
tree | 327374119c2b40b64de192534b8b6e4f242778be /src/de/danoeh/antennapod/service | |
parent | 5b58466fd21c8bc97fe00698369228ea96566c33 (diff) | |
parent | 2db89cb807ae06b0f59039307e20c32cd9052b57 (diff) | |
download | AntennaPod-b48c3807fd23df0a6d953ebdabaaf2330bc4f3d3.zip |
Merge branch 'playback-speed' into speed
Conflicts:
res/values/arrays.xml
res/values/strings.xml
src/de/danoeh/antennapod/activity/PreferenceActivity.java
src/de/danoeh/antennapod/service/PlaybackService.java
Diffstat (limited to 'src/de/danoeh/antennapod/service')
-rw-r--r-- | src/de/danoeh/antennapod/service/PlaybackService.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 99d1afa7f..afd8de68f 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -110,6 +110,7 @@ public class PlaybackService extends Service { public static final int NOTIFICATION_TYPE_BUFFER_END = 6; /** No more episodes are going to be played. */ public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7; + public static final int NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE = 8; /** * Returned by getPositionSafe() or getDurationSafe() if the playbackService @@ -395,12 +396,14 @@ public class PlaybackService extends Service { } // Intent values appear to be valid // check if already playing and playbackType is the same - } else if (media == null || playable != media + } else if (media == null + || !playable.getIdentifier().equals(media.getIdentifier()) || playbackType != shouldStream) { pause(true, false); sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); if (media == null - || playable.getIdentifier() != media.getIdentifier()) { + || !playable.getIdentifier().equals( + media.getIdentifier())) { media = playable; } @@ -1531,30 +1534,34 @@ public class PlaybackService extends Service { } public boolean canSetSpeed() { - if (media.getMediaType() == MediaType.AUDIO) { + if (media != null && media.getMediaType() == MediaType.AUDIO) { return ((AudioPlayer) player).canSetSpeed(); } return false; } public boolean canSetPitch() { - if (media.getMediaType() == MediaType.AUDIO) { + if (media != null && media.getMediaType() == MediaType.AUDIO) { return ((AudioPlayer) player).canSetPitch(); } return false; } public void setSpeed(float speed) { - if (media.getMediaType() == MediaType.AUDIO) { + if (media != null && media.getMediaType() == MediaType.AUDIO) { AudioPlayer audioPlayer = (AudioPlayer) player; if (audioPlayer.canSetSpeed()) { audioPlayer.setPlaybackSpeed(speed); + if (AppConfig.DEBUG) + Log.d(TAG, "Playback speed was set to " + speed); + sendNotificationBroadcast( + NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE, 0); } } } public void setPitch(float pitch) { - if (media.getMediaType() == MediaType.AUDIO) { + if (media != null && media.getMediaType() == MediaType.AUDIO) { AudioPlayer audioPlayer = (AudioPlayer) player; if (audioPlayer.canSetPitch()) { audioPlayer.setPlaybackPitch(pitch); @@ -1562,6 +1569,17 @@ 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 * an invalid state. This method should be used instead of calling |