diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-02-24 16:18:17 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-02-24 16:18:17 -0800 |
commit | 345be112bb6fcee482b287045f223cdb2a276ec6 (patch) | |
tree | e7eb7d04e704fdfc827395b90ed13a9edfbeeff5 /src/github | |
parent | 3f9b769df513093500bcd1466bc178cac74763b9 (diff) | |
download | dsub-345be112bb6fcee482b287045f223cdb2a276ec6.tar.gz dsub-345be112bb6fcee482b287045f223cdb2a276ec6.tar.bz2 dsub-345be112bb6fcee482b287045f223cdb2a276ec6.zip |
#289 When playlist size == 1, skip within song from prev/next buttons
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/DownloadFragment.java | 4 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 20 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java index 87cffd03..835394ae 100644 --- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -1336,7 +1336,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe // Top to Bottom swipe
else if (e2.getY() - e1.getY() > swipeDistance && Math.abs(velocityY) > swipeVelocity) {
warnIfNetworkOrStorageUnavailable();
- downloadService.seekTo(downloadService.getPlayerPosition() + 30000);
+ downloadService.seekTo(downloadService.getPlayerPosition() + DownloadService.FAST_FORWARD);
onProgressChanged();
return true;
}
@@ -1344,7 +1344,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe // Bottom to Top swipe
else if (e1.getY() - e2.getY() > swipeDistance && Math.abs(velocityY) > swipeVelocity) {
warnIfNetworkOrStorageUnavailable();
- downloadService.seekTo(downloadService.getPlayerPosition() - 8000);
+ downloadService.seekTo(downloadService.getPlayerPosition() - DownloadService.REWIND);
onProgressChanged();
return true;
}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 924f53a7..76ec8396 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -76,7 +76,6 @@ import java.net.URLEncoder; * @version $Id$ */ public class DownloadService extends Service { - private static final String TAG = DownloadService.class.getSimpleName(); public static final String CMD_PLAY = "github.daneren2005.dsub.CMD_PLAY"; @@ -86,6 +85,8 @@ public class DownloadService extends Service { public static final String CMD_PREVIOUS = "github.daneren2005.dsub.CMD_PREVIOUS"; public static final String CMD_NEXT = "github.daneren2005.dsub.CMD_NEXT"; public static final String CANCEL_DOWNLOADS = "github.daneren2005.dsub.CANCEL_DOWNLOADS"; + public static final int FAST_FORWARD = 30000; + public static final int REWIND = 10000; private RemoteControlClientHelper mRemoteControl; @@ -802,6 +803,10 @@ public class DownloadService extends Service { } public synchronized void seekTo(int position) { + if(position < 0) { + position = 0; + } + try { if (remoteState != RemoteControlState.LOCAL) { remoteController.changePosition(position / 1000); @@ -820,6 +825,13 @@ public class DownloadService extends Service { return; } + // If only one song, just skip within song + if(size() == 1) { + seekTo(getPlayerPosition() - REWIND); + return; + } + + // Restart song if played more than five seconds. if (getPlayerPosition() > 5000 || (index == 0 && getRepeatMode() != RepeatMode.ALL)) { play(index); @@ -833,6 +845,12 @@ public class DownloadService extends Service { } public synchronized void next() { + // If only one song, just skip within song + if(size() == 1) { + seekTo(getPlayerPosition() + FAST_FORWARD); + return; + } + // Delete podcast if fully listened to if(currentPlaying != null && currentPlaying.getSong() instanceof PodcastEpisode) { int duration = getPlayerDuration(); |