要从 URL 获取 JSON,请参阅我的回答 here。
之后,您可以使用this 库下载视频。您还可以串行(一个接一个)或并行下载它们。
用法:
在Application类中初始化下载器:
public XXApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
FileDownloader.init(this);
}
}
然后像这样下载。
final FileDownloadListener queueTarget = new FileDownloadListener() {
@Override
protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes) {
}
@Override
protected void connected(BaseDownloadTask task, String etag, boolean isContinue, int soFarBytes, int totalBytes) {
}
@Override
protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes) {
}
@Override
protected void blockComplete(BaseDownloadTask task) {
}
@Override
protected void retry(final BaseDownloadTask task, final Throwable ex, final int retryingTimes, final int soFarBytes) {
}
@Override
protected void completed(BaseDownloadTask task) {
}
@Override
protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes) {
}
@Override
protected void error(BaseDownloadTask task, Throwable e) {
}
@Override
protected void warn(BaseDownloadTask task) {
}
};
for (String url : URLS) {
FileDownloader.getImpl().create(url)
.setCallbackProgressTimes(0)
.setListener(queueTarget)
.ready();
}
if(serial){
FileDownloader.getImpl().start(queueTarget, true);
}