diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java | 25 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java | 45 |
2 files changed, 61 insertions, 9 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java b/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java index 35f6d37a..88cfe559 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java @@ -279,12 +279,18 @@ public class AutoMediaBrowserService extends MediaBrowserService { // music files for(Entry entry: indexes.getEntries()) { + entry.setBookmark(null); // don't resume from a bookmark in a browse listing + Bundle extras = new Bundle(); + extras.putSerializable(Constants.INTENT_EXTRA_ENTRY, entry); + extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId()); + MediaDescription description = new MediaDescription.Builder() .setTitle(entry.getTitle()) - .setMediaId(MUSIC_DIRECTORY_PREFIX + entry.getId()) + .setMediaId(entry.getId()) + .setExtras(extras) .build(); - mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_BROWSABLE)); + mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE)); } result.sendResult(mediaItems); @@ -315,15 +321,24 @@ public class AutoMediaBrowserService extends MediaBrowserService { .setTitle(entry.getTitle()) .setMediaId(MUSIC_DIRECTORY_CONTENTS_PREFIX + entry.getId()) .build(); + + mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_BROWSABLE)); } else { - // playback options for a single item + // mark individual songs as directly playable + entry.setBookmark(null); // don't resume from a bookmark in a browse listing + Bundle extras = new Bundle(); + extras.putSerializable(Constants.INTENT_EXTRA_ENTRY, entry); + extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId()); + description = new MediaDescription.Builder() .setTitle(entry.getTitle()) - .setMediaId(MUSIC_DIRECTORY_PREFIX + entry.getId()) + .setMediaId(entry.getId()) + .setExtras(extras) .build(); + + mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE)); } - mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_BROWSABLE)); } result.sendResult(mediaItems); } 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 00bca833..816a071d 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 @@ -370,6 +370,30 @@ public class RemoteControlClientLP extends RemoteControlClientBase { private void playMusicDirectory(Entry dir, boolean shuffle, boolean append, boolean playFromBookmark) { playMusicDirectory(dir.getId(), shuffle, append, playFromBookmark); } + private void playMusicDirectory(final String dirId, final boolean shuffle, final boolean append, final Entry startEntry) { + new SilentServiceTask<Void>(downloadService) { + @Override + protected Void doInBackground(MusicService musicService) throws Throwable { + MusicDirectory musicDirectory; + if(Util.isTagBrowsing(downloadService) && !Util.isOffline(downloadService)) { + musicDirectory = musicService.getAlbum(dirId, "dir", false, downloadService, null); + } else { + musicDirectory = musicService.getMusicDirectory(dirId, "dir", false, downloadService, null); + } + + List<Entry> playEntries = new ArrayList<>(); + List<Entry> allEntries = musicDirectory.getChildren(false, true); + for(Entry song: allEntries) { + if (!song.isVideo() && song.getRating() != 1) { + playEntries.add(song); + } + } + playSongs(playEntries, shuffle, append, startEntry); + + return null; + } + }.execute(); + } private void playMusicDirectory(final String dirId, final boolean shuffle, final boolean append, final boolean playFromBookmark) { new SilentServiceTask<Void>(downloadService) { @Override @@ -409,6 +433,19 @@ public class RemoteControlClientLP extends RemoteControlClientBase { private void playSongs(List<Entry> entries, boolean shuffle, boolean append) { playSongs(entries, shuffle, append, false); } + private void playSongs(List<Entry> entries, boolean shuffle, boolean append, Entry startEntry) { + if(!append) { + downloadService.clear(); + } + + int startIndex = entries.indexOf(startEntry); + int startPosition = 0; + if(startEntry.getBookmark() != null) { + Bookmark bookmark = startEntry.getBookmark(); + startPosition = bookmark.getPosition(); + } + downloadService.download(entries, false, true, !append, shuffle, startIndex, startPosition); + } private void playSongs(List<Entry> entries, boolean shuffle, boolean append, boolean resumeFromBookmark) { if(!append) { downloadService.clear(); @@ -429,7 +466,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase { } } - downloadService.download(entries, false, !append, false, shuffle, startIndex, startPosition); + downloadService.download(entries, false, true, !append, shuffle, startIndex, startPosition); } private void noResults() { @@ -564,13 +601,13 @@ public class RemoteControlClientLP extends RemoteControlClientBase { playSong(entry, true); } - // Currently only happens when playing bookmarks so we should be looking up parent + // Enqueue an entire directory when selecting a bookmark or a song String childId = extras.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID, null); if(childId != null) { if(Util.isTagBrowsing(downloadService) && !Util.isOffline(downloadService)) { - playMusicDirectory(entry.getAlbumId(), shuffle, playLast, true); + playMusicDirectory(entry.getAlbumId(), shuffle, playLast, entry); } else { - playMusicDirectory(entry.getParent(), shuffle, playLast, true); + playMusicDirectory(entry.getParent(), shuffle, playLast, entry); } } } |