要從URL獲取JSON,請參閱我的回答here。
之後您可以使用this庫下載視頻。您也可以將它們串行(逐個)或並行下載。
用法: 初始化下載應用程序中的類:
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);
}
我想要做的是從服務器獲取視頻列表,並在本地下載視頻,然後在視頻播放器上播放,只有在下載完成後才能播放。 – Aldo
如果你搜索,已經有很多答案..你到目前爲止嘗試過什麼?沒有,因爲你沒有搜索? –
我確實搜索過,我在這裏寫信尋找更好的指南。對不起,我只是一個初學者。 如果你可以幫助更好的解決方案或想法會很好。 謝謝。 – Aldo