【发布时间】:2023-03-20 07:02:01
【问题描述】:
我正在使用很棒的 Cling 库来扫描我的网络以查找 UPnP 设备。我的目标是组装一个小的 DLNA 库浏览器,这样我就可以学习这项技术。到目前为止,我已经能够 1. 扫描网络并连接 UPnP 设备,2. 扫描每个远程设备并确定它是否运行 DLNA 服务,以及 3. 浏览已知节点的直接子节点。简而言之,这是我能够运行所有这些的方法:
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 服务器,现在如何获取这些根存储目录?在上面给出的浏览命令中,我实际上必须传递一些索引的字符串表示来获取“音乐”或“视频”等。如何获得顶级存储目录,然后如何浏览这些目录中的每一个?我的目标是至少构建一个简单的浏览器。
【问题讨论】: