[Android] Load tracks with 'PlayAll'

Geoffrey Métais git at videolan.org
Wed Sep 26 17:48:08 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Sep 26 17:46:33 2018 +0200| [6353fb085c0f71eb19ad5e8fb752f9b147c6b948] | committer: Geoffrey Métais

Load tracks with 'PlayAll'

> https://code.videolan.org/videolan/vlc-android/commit/6353fb085c0f71eb19ad5e8fb752f9b147c6b948
---

 .../org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java |  8 +++-----
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java | 12 +-----------
 .../src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java     |  2 +-
 3 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 296798b50..dd0623627 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -56,7 +56,6 @@ import org.videolan.vlc.viewmodels.paged.PagedAlbumsModel;
 import org.videolan.vlc.viewmodels.paged.PagedTracksModel;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeRefreshLayout.OnRefreshListener, TabLayout.OnTabSelectedListener {
@@ -272,14 +271,13 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
     @Override
     @SuppressWarnings("unchecked")
     public void onFabPlayClick(View view) {
-        final List<MediaWrapper> list ;
         if (mViewPager.getCurrentItem() == 0) {
-            list = new ArrayList<>();
+            final List<MediaWrapper> list = new ArrayList<>();
             for (MediaLibraryItem item : albumModel.getAll())
                 list.addAll(Util.arrayToArrayList(item.getTracks()));
+            MediaUtils.INSTANCE.openList(getActivity(), list, 0);
         } else {
-            list = Arrays.asList(tracksModel.getAll());
+            MediaUtils.INSTANCE.playAll(view.getContext(), tracksModel, 0, false);
         }
-        MediaUtils.INSTANCE.openList(getActivity(), list, 0);
     }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index fb59270cc..fb8756db2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -61,10 +61,6 @@ import org.videolan.vlc.viewmodels.paged.PagedGenresModel;
 import org.videolan.vlc.viewmodels.paged.PagedPlaylistsModel;
 import org.videolan.vlc.viewmodels.paged.PagedTracksModel;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
 public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefreshLayout.OnRefreshListener, ViewPager.OnPageChangeListener, TabLayout.OnTabSelectedListener {
     public final static String TAG = "VLC/AudioBrowserFragment";
 
@@ -231,13 +227,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
 
     @Override
     public void onFabPlayClick(View view) {
-        final List<MediaWrapper> list = Arrays.asList(tracksModel.getAll());
-        final int count = list.size();
-        if (count > 0) {
-            final Random rand = new Random();
-            int randomSong = rand.nextInt(count);
-            MediaUtils.INSTANCE.openList(getActivity(), list, randomSong, true);
-        }
+        MediaUtils.INSTANCE.playAll(view.getContext(), tracksModel, 0, true);
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
index bfcfd004f..ec6d951d9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
@@ -198,7 +198,7 @@ public abstract class BaseAudioBrowser extends MediaBrowserFragment<MLPagedModel
                 MediaUtils.INSTANCE.openArray(requireActivity(), media.getTracks(), 0);
                 break;
             case Constants.CTX_PLAY_ALL:
-                MediaUtils.INSTANCE.openArray(requireActivity(), (MediaWrapper[]) getViewModel().getAll(), position);
+                MediaUtils.INSTANCE.playAll(requireContext(), getViewModel(), position, false);
                 break;
             case Constants.CTX_INFORMATION:
                 showInfoDialog(media);



More information about the Android mailing list