[Android] Load all media in a folder from browser
Geoffrey Métais
git at videolan.org
Wed Apr 29 14:15:06 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr 28 12:16:34 2015 +0200| [bbacc6123fecfe6e3dc4fdf66d361d23c77f0b03] | committer: Thomas Guillem
Load all media in a folder from browser
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=bbacc6123fecfe6e3dc4fdf66d361d23c77f0b03
---
.../videolan/vlc/gui/browser/BaseBrowserAdapter.java | 17 +++++++++++++++--
vlc-android/src/org/videolan/vlc/util/Util.java | 18 ++++++++++++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index 0179675..431658f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -34,10 +34,12 @@ import org.videolan.libvlc.Media;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.MediaComparators;
+import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedList;
public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final String TAG = "VLC/BaseBrowserAdapter";
@@ -92,8 +94,19 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
MediaWrapper mw = (MediaWrapper) getItem(holder.getPosition());
if (mw.getType() == MediaWrapper.TYPE_DIR)
fragment.browse(mw, holder.getPosition());
- else
- Util.openMedia(v.getContext(), mw);
+ else {
+ int position = 0;
+ LinkedList<String> mediaLocations = new LinkedList<String>();
+ MediaWrapper mediaItem;
+ for (Object item : mMediaList)
+ if (item instanceof MediaWrapper){
+ mediaItem = (MediaWrapper) item;
+ mediaLocations.add(mediaItem.getLocation());
+ if (mediaItem.equals(mw))
+ position = mediaLocations.size()-1;
+ }
+ Util.openList(v.getContext(), mediaLocations, position);
+ }
}
});
if (hasContextMenu) {
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index b9bc06d..f574406 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -211,6 +211,24 @@ public class Util {
openStream(context, mrl);
}
+ public static void openList(Context context, final List<String> list, final int position){
+ VLCCallbackTask task = new VLCCallbackTask(context){
+ @Override
+ public void run() {
+ AudioServiceController c = AudioServiceController.getInstance();
+
+ /* Use the audio player by default. If a video track is
+ * detected, then it will automatically switch to the video
+ * player. This allows us to support more types of streams
+ * (for example, RTSP and TS streaming) where ES can be
+ * dynamically adapted rather than a simple scan.
+ */
+ c.load(list, position);
+ }
+ };
+ task.execute();
+ }
+
public static void openStream(Context context, final String uri){
VLCCallbackTask task = new VLCCallbackTask(context){
@Override
More information about the Android
mailing list