aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/util/compat
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-10-22 17:52:02 -0700
committerScott Jackson <daneren2005@gmail.com>2015-10-22 17:52:02 -0700
commit105e63e74994004c510fdada63d03086bbb56752 (patch)
tree3cb9284deb90e47da8f7d85d699c4718219a4a0e /app/src/main/java/github/daneren2005/dsub/util/compat
parent15e0bf9982b5235b3934c05093ff6b517524d86b (diff)
downloaddsub-105e63e74994004c510fdada63d03086bbb56752.tar.gz
dsub-105e63e74994004c510fdada63d03086bbb56752.tar.bz2
dsub-105e63e74994004c510fdada63d03086bbb56752.zip
#480 Add playlists browsing from Auto
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/util/compat')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java35
1 files changed, 33 insertions, 2 deletions
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 c9f8cab8..456446f3 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
@@ -338,14 +338,31 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
}.execute();
}
+ private void playPlaylist(final Playlist playlist, final boolean shuffle, final boolean append) {
+ new SilentServiceTask<Void>(downloadService) {
+ @Override
+ protected Void doInBackground(MusicService musicService) throws Throwable {
+ MusicDirectory musicDirectory = musicService.getPlaylist(false, playlist.getId(), playlist.getName(), downloadService, null);
+ playSongs(musicDirectory.getChildren(), shuffle, append);
+
+ return null;
+ }
+ }.execute();
+ }
+
private void playSong(MusicDirectory.Entry entry) {
List<MusicDirectory.Entry> entries = new ArrayList<>();
entries.add(entry);
playSongs(entries);
}
private void playSongs(List<MusicDirectory.Entry> entries) {
- downloadService.clear();
- downloadService.download(entries, false, true, false, false);
+ playSongs(entries, false, false);
+ }
+ private void playSongs(List<MusicDirectory.Entry> entries, boolean shuffle, boolean append) {
+ if(!append) {
+ downloadService.clear();
+ }
+ downloadService.download(entries, false, true, false, shuffle);
}
private void noResults() {
@@ -450,6 +467,20 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
}
}
+ public void onPlayFromMediaId (String mediaId, Bundle extras) {
+ if(extras == null) {
+ return;
+ }
+
+ boolean shuffle = extras.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false);
+ boolean playLast = extras.getBoolean(Constants.INTENT_EXTRA_PLAY_LAST, false);
+ String playlistId = extras.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, null);
+ if(playlistId != null) {
+ Playlist playlist = new Playlist(playlistId, null);
+ playPlaylist(playlist, shuffle, playLast);
+ }
+ }
+
@Override
public void onCustomAction(String action, Bundle extras) {
if(CUSTOM_ACTION_THUMBS_UP.equals(action)) {