I use the awesome Cling library to scan my network for UPnP devices. My goal is to put together a little DLNA library so that I can learn this technology. Until now, I could 1. scan the network and connect UPnP devices, 2. check each remote device and determine if it has DLNA service, and 3. browse the immediate children of known nodes. In short, this is my method, which is able to run all of this:
public void remoteDeviceAdded(Registry registry, RemoteDevice device) { logger.debug("remote device added: {}[{}]", device.getDetails().getFriendlyName(), device.getType().getType()); if (device.getType().getType().equals("MediaServer")) { for (RemoteService service : device.getServices()) { if (service.getServiceType().getType().equals("ContentDirectory")) { // '1' is Music, '2' is Video, '3' is Pictures this.service.getControlPoint().execute(new Browse(service, "3", BrowseFlag.DIRECT_CHILDREN) { @Override public void received(ActionInvocation arg0, DIDLContent didl) { logger.debug("found {} items.", didl.getItems().size()); } @Override public void updateStatus(Status arg0) { }; @Override public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) { }; }); } } } }
I know this probably looks like a terrible mess, but it works :) When I look into the debugger, I see what I have. However, unlike the manual instructions here , I do not get any real multimedia elements, but only storage directories in the search results. This approach makes sense because DLNA organizes things in a hierarchy as follows:
Music All Music Artists Fleetwood Mac ... Albums ... Video All Video Folders ...
My question is, what is the easiest way to browse through these folders and walk through the hierarchy? I am already at the point where I am connected to the UPnP DLNA server I was looking for, now how can I get these root storage directories? In the above review command, I have to actually pass a string representation of some index to get “Music” or “Video” or the like. How to get top level storage directories, then how can I view each of these directories? My goal is to at least create a simple browser.
Naftuli Kay
source share