aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorowner <owner@DeeDee-Laptop>2012-11-24 08:27:49 -0800
committerowner <owner@DeeDee-Laptop>2012-11-24 08:27:49 -0800
commit836141bc69e30848adf049a50a95cf4d81c38cc1 (patch)
treed071d256ed7b8c2529693c49e65d3b69d92276cf
parent2e3820f52ddf5720053db60b2d9fa251e0089149 (diff)
downloaddsub-836141bc69e30848adf049a50a95cf4d81c38cc1.tar.gz
dsub-836141bc69e30848adf049a50a95cf4d81c38cc1.tar.bz2
dsub-836141bc69e30848adf049a50a95cf4d81c38cc1.zip
Added support for setting genre/year range in services
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/MusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java14
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java12
7 files changed, 35 insertions, 6 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
index c9233d01..fe0a3f19 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -191,8 +191,8 @@ public class CachedMusicService implements MusicService {
}
@Override
- public MusicDirectory getRandomSongs(int size, String folder, Context context, ProgressListener progressListener) throws Exception {
- return musicService.getRandomSongs(size, folder, context, progressListener);
+ public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception {
+ return musicService.getRandomSongs(size, folder, genre, startYear, endYear, context, progressListener);
}
@Override
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
index d11c8285..f68f8db6 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
@@ -38,6 +38,8 @@ public interface DownloadService {
void setShufflePlayEnabled(boolean enabled);
boolean isShufflePlayEnabled();
+
+ void setShuffleParams(String genre, String startYear, String endYear);
void shuffle();
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 38b3fe03..aae4829a 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -299,6 +299,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
public synchronized boolean isShufflePlayEnabled() {
return shufflePlay;
}
+
+ @Override
+ public void setShuffleParams(String genre, String startYear, String endYear) {
+ shufflePlayBuffer.setOptions(genre, startYear, endYear);
+ }
@Override
public synchronized void shuffle() {
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
index 67e4bed5..98951853 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
@@ -75,7 +75,7 @@ public interface MusicService {
MusicDirectory getAlbumList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception;
- MusicDirectory getRandomSongs(int size, String folder, Context context, ProgressListener progressListener) throws Exception;
+ MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception;
Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, boolean saveToFile, ProgressListener progressListener) throws Exception;
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
index ce353740..a12a169e 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -365,7 +365,7 @@ public class OfflineMusicService extends RESTMusicService {
}
@Override
- public MusicDirectory getRandomSongs(int size, String folder, Context context, ProgressListener progressListener) throws Exception {
+ public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception {
File root = FileUtil.getMusicDirectory(context);
List<File> children = new LinkedList<File>();
listFilesRecursively(root, children);
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index 00e9f2b1..75ec6142 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -495,7 +495,7 @@ public class RESTMusicService implements MusicService {
}
@Override
- public MusicDirectory getRandomSongs(int size, String musicFolderId, Context context, ProgressListener progressListener) throws Exception {
+ public MusicDirectory getRandomSongs(int size, String musicFolderId, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception {
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setSoTimeout(params, SOCKET_READ_TIMEOUT_GET_RANDOM_SONGS);
@@ -509,6 +509,18 @@ public class RESTMusicService implements MusicService {
names.add("musicFolderId");
values.add(musicFolderId);
}
+ if(genre != null) {
+ names.add("genre");
+ values.add(genre);
+ }
+ if(startYear != null) {
+ names.add("fromYear");
+ values.add(startYear);
+ }
+ if(endYear != null) {
+ names.add("toYear");
+ values.add(endYear);
+ }
Reader reader = getReader(context, progressListener, "getRandomSongs", params, names, values);
try {
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java
index f30f3d6d..3cc26057 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java
@@ -45,6 +45,10 @@ public class ShufflePlayBuffer {
private Context context;
private int currentServer;
private String currentFolder;
+
+ private String genre;
+ private String startYear;
+ private String endYear;
public ShufflePlayBuffer(Context context) {
this.context = context;
@@ -88,7 +92,7 @@ public class ShufflePlayBuffer {
MusicService service = MusicServiceFactory.getMusicService(context);
int n = CAPACITY - buffer.size();
String folder = Util.getSelectedMusicFolderId(context);
- MusicDirectory songs = service.getRandomSongs(n, folder, context, null);
+ MusicDirectory songs = service.getRandomSongs(n, folder, genre, startYear, endYear, context, null);
synchronized (buffer) {
buffer.addAll(songs.getChildren());
@@ -108,5 +112,11 @@ public class ShufflePlayBuffer {
}
}
}
+
+ public void setOptions(String genre, String startYear, String endYear) {
+ this.genre = genre;
+ this.startYear = startYear;
+ this.endYear = endYear;
+ }
}