[Android] MediaBrowser: add enum Discover, hide discover string from API
Thomas Guillem
git at videolan.org
Tue Dec 22 10:44:07 CET 2015
vlc-android | branch: 1.7.x | Thomas Guillem <thomas at gllm.fr> | Wed Dec 2 14:50:27 2015 +0100| [8ee26c152470d089ed961b8ffddc595e8d895f84] | committer: Geoffrey Métais
MediaBrowser: add enum Discover, hide discover string from API
Build.Config from libvlc is never Debug and dsm was never loaded.
(cherry picked from commit c606130290ef70dacd5504a1d48a4e4684b136d9)
Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>
> https://code.videolan.org/videolan/vlc-android/commit/8ee26c152470d089ed961b8ffddc595e8d895f84
---
.../src/org/videolan/libvlc/util/MediaBrowser.java | 34 ++++++++++++----------
.../vlc/gui/browser/NetworkBrowserFragment.java | 11 ++++++-
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java b/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java
index aa8b785..fb15ab1 100644
--- a/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java
+++ b/libvlc/src/org/videolan/libvlc/util/MediaBrowser.java
@@ -24,7 +24,6 @@ import android.net.Uri;
import java.util.ArrayList;
-import org.videolan.BuildConfig;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaDiscoverer;
@@ -33,12 +32,16 @@ import org.videolan.libvlc.MediaList;
public class MediaBrowser {
private static final String TAG = "LibVLC/util/MediaBrowser";
- private static final String[] DISCOVERER_LIST = BuildConfig.DEBUG ? new String[]{
- "dsm", // Netbios discovery via libdsm
- "upnp",
- // "bonjour",
- // "mdns"
- } : new String[]{"upnp"} ; //Only UPnP for release
+ public static enum Discover {
+ UPNP("upnp"),
+ SMB("dsm")
+ ;
+
+ private final String str;
+ Discover(String str) {
+ this.str = str;
+ }
+ }
private final LibVLC mLibVlc;
private final ArrayList<MediaDiscoverer> mMediaDiscoverers = new ArrayList<MediaDiscoverer>();
@@ -128,21 +131,22 @@ public class MediaBrowser {
}
/**
- * Discover networks shares using available MediaDiscoverers
+ * Discover networks shares using a list of Discoverers
*/
- public synchronized void discoverNetworkShares() {
+ public synchronized void discoverNetworkShares(Discover discovers[]) {
reset();
- for (String discovererName : DISCOVERER_LIST)
- startMediaDiscoverer(discovererName);
+ for (Discover discover : discovers)
+ startMediaDiscoverer(discover.str);
}
/**
- * Discover networks shares using specified MediaDiscoverer
+ * Discover networks shares using a specified Discoverer
* @param discovererName
*/
- public synchronized void discoverNetworkShares(String discovererName) {
- reset();
- startMediaDiscoverer(discovererName);
+ public synchronized void discoverNetworkShares(Discover discover) {
+ Discover discovers[] = new Discover[1];
+ discovers[0] = discover;
+ discoverNetworkShares(discovers);
}
/**
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index 1b05fce..6e474fc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -32,6 +32,8 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
+import org.videolan.libvlc.util.MediaBrowser;
+import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
@@ -41,6 +43,13 @@ import java.util.ArrayList;
public class NetworkBrowserFragment extends BaseBrowserFragment {
+ private static MediaBrowser.Discover DISCOVER_LIST[] = BuildConfig.DEBUG ? new MediaBrowser.Discover[] {
+ MediaBrowser.Discover.UPNP,
+ MediaBrowser.Discover.SMB,
+ } : new MediaBrowser.Discover[] {
+ MediaBrowser.Discover.UPNP,
+ };
+
public NetworkBrowserFragment() {
ROOT = "smb";
mHandler = new BrowserFragmentHandler(this);
@@ -99,7 +108,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
}
mAdapter.addItem("Network favorites", false, true);
}
- mMediaBrowser.discoverNetworkShares();
+ mMediaBrowser.discoverNetworkShares(DISCOVER_LIST);
}
@Override
More information about the Android
mailing list