我正在使用真棒Cling
库扫描我的网络以查找UPnP设备。我的目标是拼凑一个DLNA库浏览器,以便我可以学习这项技术。到目前为止,我已能够1.扫描网络并获得连接的UPnP设备,2.扫描每个远程设备并确定它是否运行DLNA服务,以及3.浏览已知节点的直接子节点。总之,这是我的方法,它能够运行所有这一切:在Cling中获取所有DLNA根存储目录?
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) { };
});
}
}
}
}
我知道,它可能看起来像一个乌七八糟,它是,但它的工作原理:)当我放到一个调试器,我可以看到我有什么。但是,与指南here的说明不同,我没有找回任何实际的媒体项目,只是浏览结果中的存储目录。这种有意义的,因为DLNA组织到的东西,像这样一个层次结构:
Music
All Music
Artists
Fleetwood Mac
...
Albums
...
Video
All Video
Folders
...
我的问题是,什么是浏览这些文件夹,并通过层次攀登最简单的方法?我已经处于连接到我正在寻找的UPnP DLNA服务器的地步,现在我该如何获得这些根存储目录?在上面给出的浏览命令中,我必须实际传递一些索引的字符串表示以获得“音乐”或“视频”等。如何获取最高级别的存储目录,然后如何浏览这些目录中的每一个?我的目标是至少建立一个简单的浏览器。
您是如何在获得该物品后成功获取文件列表的?我有容器,但getItems()总是空的。 – Nifhel 2013-09-19 15:45:10