diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-09-04 13:32:48 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-09-04 13:32:48 +0200 |
commit | 8a76daeeaf09c657c19a33ec4fffd3ae975b3412 (patch) | |
tree | 06fda47c32ba9c3dd9dd9d7ffc9c74de94ebca28 /src | |
parent | af2595f2d0f00515f8cc8f65167bd746e4ca9bc0 (diff) | |
download | AntennaPod-8a76daeeaf09c657c19a33ec4fffd3ae975b3412.zip |
Play/Pause button now toggles startWhenPrepared when PlaybackService is
in PREPARING state
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/activity/MediaplayerActivity.java | 29 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/service/PlaybackService.java | 16 |
2 files changed, 40 insertions, 5 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index c55b06855..771450cbf 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -90,13 +90,25 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity protected OnClickListener playbuttonListener = new OnClickListener() { @Override public void onClick(View v) { - if (status == PlayerStatus.PLAYING) { - playbackService.pause(true); - } else if (status == PlayerStatus.PAUSED - || status == PlayerStatus.PREPARED) { - playbackService.play(); + if (playbackService != null) { + switch (status) { + case PLAYING: + playbackService.pause(true); + break; + case PAUSED: + case PREPARED: + playbackService.play(); + break; + case PREPARING: + playbackService.setStartWhenPrepared(!playbackService + .isStartWhenPrepared()); + } + } else { + Log.w(TAG, + "Play/Pause button was pressed, but playbackservice was null!"); } } + }; protected ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { @@ -410,6 +422,13 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity case PREPARING: postStatusMsg(R.string.player_preparing_msg); loadMediaInfo(); + if (playbackService != null) { + if (playbackService.isStartWhenPrepared()) { + butPlay.setImageResource(R.drawable.av_pause); + } else { + butPlay.setImageResource(R.drawable.av_play); + } + } break; case STOPPED: postStatusMsg(R.string.player_stopped_msg); diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index a83e0e2d6..b278012e5 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -658,6 +658,11 @@ public class PlaybackService extends Service { updateWidget(); refreshRemoteControlClientState(); } + + /** Send ACTION_PLAYER_STATUS_CHANGED without changing the status attribute. */ + private void postStatusUpdateIntent() { + setStatus(status); + } private void sendNotificationBroadcast(int type, int code) { Intent intent = new Intent(ACTION_PLAYER_NOTIFICATION); @@ -992,4 +997,15 @@ public class PlaybackService extends Service { return player; } + public boolean isStartWhenPrepared() { + return startWhenPrepared; + } + + public void setStartWhenPrepared(boolean startWhenPrepared) { + this.startWhenPrepared = startWhenPrepared; + postStatusUpdateIntent(); + } + + + } |