diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-05-02 07:47:48 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-05-02 07:47:48 -0700 |
commit | ca8b3539a6401c63e81f1fd666ba85e5dfc24350 (patch) | |
tree | 4268149809791fc5f9155b8be6590b0bf1eea38d /subsonic-android | |
parent | f4ddd0b88224c98ae32384972c8c7700fcdddf1a (diff) | |
download | dsub-ca8b3539a6401c63e81f1fd666ba85e5dfc24350.tar.gz dsub-ca8b3539a6401c63e81f1fd666ba85e5dfc24350.tar.bz2 dsub-ca8b3539a6401c63e81f1fd666ba85e5dfc24350.zip |
Did not mean to include this in last commit
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 68917d9e..8b37e1e2 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -223,51 +223,42 @@ public class DownloadServiceLifecycleSupport { } private void handleKeyEvent(KeyEvent event) { - if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() > 0) { - switch (event.getKeyCode()) { - case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: - case KeyEvent.KEYCODE_MEDIA_PREVIOUS: - downloadService.seekTo(downloadService.getPlayerPosition() - 10000); - break; - case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: - case KeyEvent.KEYCODE_MEDIA_NEXT: - downloadService.seekTo(downloadService.getPlayerPosition() + 10000); - break; - } - } else if(event.getAction() == KeyEvent.ACTION_UP) { - switch (event.getKeyCode()) { - case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE: - case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: - case KeyEvent.KEYCODE_HEADSETHOOK: - downloadService.togglePlayPause(); - break; - case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: - case KeyEvent.KEYCODE_MEDIA_PREVIOUS: - downloadService.previous(); - break; - case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: - case KeyEvent.KEYCODE_MEDIA_NEXT: - if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) { - downloadService.next(); - } - break; - case RemoteControlClient.FLAG_KEY_MEDIA_STOP: - case KeyEvent.KEYCODE_MEDIA_STOP: - downloadService.stop(); - break; - case RemoteControlClient.FLAG_KEY_MEDIA_PLAY: - case KeyEvent.KEYCODE_MEDIA_PLAY: - if(downloadService.getPlayerState() != PlayerState.STARTED) { - downloadService.start(); - } - break; - case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE: - case KeyEvent.KEYCODE_MEDIA_PAUSE: - downloadService.pause(); - default: - break; - } - } + if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0) { + return; + } + + switch (event.getKeyCode()) { + case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE: + case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: + case KeyEvent.KEYCODE_HEADSETHOOK: + downloadService.togglePlayPause(); + break; + case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: + case KeyEvent.KEYCODE_MEDIA_PREVIOUS: + downloadService.previous(); + break; + case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: + case KeyEvent.KEYCODE_MEDIA_NEXT: + if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1) { + downloadService.next(); + } + break; + case RemoteControlClient.FLAG_KEY_MEDIA_STOP: + case KeyEvent.KEYCODE_MEDIA_STOP: + downloadService.stop(); + break; + case RemoteControlClient.FLAG_KEY_MEDIA_PLAY: + case KeyEvent.KEYCODE_MEDIA_PLAY: + if(downloadService.getPlayerState() != PlayerState.STARTED) { + downloadService.start(); + } + break; + case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE: + case KeyEvent.KEYCODE_MEDIA_PAUSE: + downloadService.pause(); + default: + break; + } } /** |