Commit 76f6f2f7 authored by Thomas Guillem's avatar Thomas Guillem

MediaBrowser: use MediaDiscoverer.getServices

parent 600a2926
......@@ -22,6 +22,7 @@ package org.videolan.libvlc.util;
import android.net.Uri;
import android.support.annotation.MainThread;
import android.util.Log;
import java.util.ArrayList;
......@@ -31,18 +32,7 @@ import org.videolan.libvlc.MediaDiscoverer;
import org.videolan.libvlc.MediaList;
public class MediaBrowser {
private static final String TAG = "LibVLC/util/MediaBrowser";
public enum Discover {
UPNP("upnp"),
SMB("dsm")
;
private final String str;
Discover(String str) {
this.str = str;
}
}
private static final String TAG = "MediaBrowser";
private final LibVLC mLibVlc;
private final ArrayList<MediaDiscoverer> mMediaDiscoverers = new ArrayList<MediaDiscoverer>();
......@@ -134,24 +124,29 @@ public class MediaBrowser {
}
/**
* Discover networks shares using a list of Discoverers
* Discover all networks shares
*/
@MainThread
public void discoverNetworkShares(Discover discovers[]) {
public void discoverNetworkShares() {
reset();
for (Discover discover : discovers)
startMediaDiscoverer(discover.str);
final MediaDiscoverer.Service services[] =
MediaDiscoverer.getServices(mLibVlc, MediaDiscoverer.Service.Category.Lan);
if (services == null)
return;
for (MediaDiscoverer.Service service : services) {
Log.i(TAG, "starting " + service.name + " discover (" + service.longName + ")");
startMediaDiscoverer(service.name);
}
}
/**
* Discover networks shares using a specified Discoverer
* @param discovererName
* @param serviceName see {@link MediaDiscoverer.Service.Category#name}
*/
@MainThread
public void discoverNetworkShares(Discover discover) {
Discover discovers[] = new Discover[1];
discovers[0] = discover;
discoverNetworkShares(discovers);
public void discoverNetworkShares(String serviceName) {
reset();
startMediaDiscoverer(serviceName);
}
/**
......
......@@ -113,7 +113,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment implements View.
protected void browseRoot() {
updateFavorites();
mAdapter.setTop(mAdapter.getItemCount());
mMediaBrowser.discoverNetworkShares(Util.NETWORK_DISCOVER_LIST);
mMediaBrowser.discoverNetworkShares();
}
@Override
......
......@@ -74,7 +74,7 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
if (mUri != null)
mMediaBrowser.browse(mUri, true);
else
mMediaBrowser.discoverNetworkShares(Util.NETWORK_DISCOVER_LIST);
mMediaBrowser.discoverNetworkShares();
((BrowserActivityInterface)getActivity()).showProgress(true);
}
}
......
......@@ -36,7 +36,7 @@ public class NetworkBrowserFragment extends MediaSortedFragment {
public static final String TAG = "VLC/NetworkBrowserFragment";
protected void browseRoot() {
mMediaBrowser.discoverNetworkShares(Util.NETWORK_DISCOVER_LIST);
mMediaBrowser.discoverNetworkShares();
}
protected void addMedia(Media media){
......
......@@ -88,9 +88,4 @@ public class Util {
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
public static final MediaBrowser.Discover NETWORK_DISCOVER_LIST[] = new MediaBrowser.Discover[] {
MediaBrowser.Discover.UPNP,
MediaBrowser.Discover.SMB,
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment