您如何跟踪Vget的下载进度?
String url = textField.getText();
String path = fpath;
VGet v = new VGet(new URL(url), new File(path));
//Should track v.download(); download progress
v.download();
答案 0 :(得分:0)
在他们的github页面上显示了如何做。
long now = System.currentTimeMillis();
if (now - 1000 > last) {
last = now;
String parts = "";
for (VideoFileInfo dinfo : dinfoList) {
SpeedInfo speedInfo = getSpeedInfo(dinfo);
speedInfo.step(dinfo.getCount());
List<Part> pp = dinfo.getParts();
if (pp != null) {
// multipart download
for (Part p : pp) {
if (p.getState().equals(States.DOWNLOADING)) {
parts += String.format("part#%d(%.2f) ", p.getNumber(),
p.getCount() / (float) p.getLength());
}
}
}
System.out.println(String.format("file:%d - %s %.2f %s (%s)", dinfoList.indexOf(dinfo),
videoinfo.getState(), dinfo.getCount() / (float) dinfo.getLength(), parts,
formatSpeed(speedInfo.getCurrentSpeed())));
}
有关完整代码,请查看其github页面here