aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-06-08 17:37:11 -0700
committerScott Jackson <daneren2005@gmail.com>2016-06-08 17:37:11 -0700
commit6ac63bba55d94a335889207adb5e0f9c806a0a92 (patch)
treed41f30663af6c7d4327324403d549f6e38cb43b2 /app/src/main/java
parent9fac439fd85487a165132431f4af74507218332e (diff)
downloaddsub-6ac63bba55d94a335889207adb5e0f9c806a0a92.tar.gz
dsub-6ac63bba55d94a335889207adb5e0f9c806a0a92.tar.bz2
dsub-6ac63bba55d94a335889207adb5e0f9c806a0a92.zip
Fixes #704: Allow rewind/fast forward in Auto + Bluetooth controls
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java27
4 files changed, 27 insertions, 13 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index c8e99f51..8a6df2ab 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -1189,7 +1189,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
this.currentPlaying = currentPlaying;
setupSubtitle(currentPlayingIndex);
- if(currentPlaying != null && currentPlaying.getSong() != null && (currentPlaying.getSong().isPodcast() || currentPlaying.getSong().isAudioBook())) {
+ if(currentPlaying != null && !currentPlaying.isSong()) {
previousButton.setVisibility(View.GONE);
nextButton.setVisibility(View.GONE);
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
index 20126f01..e4bab798 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
@@ -84,6 +84,9 @@ public class DownloadFile implements BufferFile {
public MusicDirectory.Entry getSong() {
return song;
}
+ public boolean isSong() {
+ return song.isSong();
+ }
public Context getContext() {
return context;
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index ff260931..eb55ba93 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1163,8 +1163,8 @@ public class DownloadService extends Service {
}
// If only one song, just skip within song
- if(size() == 1) {
- seekTo(getPlayerPosition() - REWIND);
+ if(size() == 1 || (currentPlaying != null && !currentPlaying.isSong())) {
+ rewind();
return;
}
@@ -1189,8 +1189,8 @@ public class DownloadService extends Service {
}
public synchronized void next(boolean forceCutoff, boolean forceStart) {
// If only one song, just skip within song
- if(size() == 1) {
- seekTo(getPlayerPosition() + FAST_FORWARD);
+ if(size() == 1 || (currentPlaying != null && !currentPlaying.isSong())) {
+ fastForward();
return;
} else if(playerState == PREPARING || playerState == PREPARED) {
return;
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
index d210fbb0..d97a859b 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
@@ -145,11 +145,17 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
position = downloadService.getPlayerPosition();
}
builder.setState(newState, position, 1.0f);
- builder.setActions(getPlaybackActions());
-
DownloadFile downloadFile = downloadService.getCurrentPlaying();
+ Entry entry = null;
+ boolean isSong = true;
if(downloadFile != null) {
- Entry entry = downloadFile.getSong();
+ entry = downloadFile.getSong();
+ isSong = entry.isSong();
+ }
+
+ builder.setActions(getPlaybackActions(isSong));
+
+ if(entry != null) {
addCustomActions(entry, builder);
builder.setActiveQueueItemId(entry.getId().hashCode());
}
@@ -231,7 +237,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
return mediaSession;
}
- protected long getPlaybackActions() {
+ protected long getPlaybackActions(boolean isSong) {
long actions = PlaybackState.ACTION_PLAY |
PlaybackState.ACTION_PAUSE |
PlaybackState.ACTION_SEEK_TO |
@@ -239,10 +245,15 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
int currentIndex = downloadService.getCurrentPlayingIndex();
int size = downloadService.size();
- if(currentIndex > 0) {
+ if(isSong) {
+ if (currentIndex > 0) {
+ actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS;
+ }
+ if (currentIndex < size - 1) {
+ actions |= PlaybackState.ACTION_SKIP_TO_NEXT;
+ }
+ } else {
actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS;
- }
- if(currentIndex < size - 1) {
actions |= PlaybackState.ACTION_SKIP_TO_NEXT;
}
@@ -311,7 +322,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
return null;
}
-
+
private void playFromParent(Entry parent) throws Exception {
List<Entry> songs = new ArrayList<>();
getSongsRecursively(parent, songs);