Aspsine / MultiThreadDownload

Android Multi-Thread Download library
908 stars 284 forks source link

Speed limitation #58

Open ghost opened 8 years ago

ghost commented 8 years ago

I need download speed limitation for each or all download tasks, and is able to set in configuration or on downloadRequest init. It is possible?

Aspsine commented 8 years ago

The lib isn't support speed limitaion for now. Acturally, I haven't thought about it. Do you have some ideas?

ghost commented 8 years ago

It would be nice to implement this. I have an Ideas but I don't know how to get this done. I saw somewhere multi thread download lib with speed limitation, so it is possible.

ghost commented 8 years ago

I think I made something by calling

DownloadRequest request = new DownloadRequest.Builder()
                            .setTitle(getFileName()+".mp3")
                            .setUri(item.getLink())
                            .setTag(item.getResult().getTag())
                            .setFolder(getDownloadFolder())
                            .setMaxRate(300)//kBps
                            .setTasks(1)//threads
                            .setRateEnabled(true)// default false
                            .build();
    DownloadConfiguration downloadConfiguration = new DownloadConfiguration();
    downloadConfiguration.setMaxThreadNum(10);
    downloadConfiguration.setThreadNum(3);
    downloadConfiguration.setTotalRateLimitEnabled(true);//and this overrides download request if reqvest is false
    downloadConfiguration.setRateLimit(500);// override 
    DownloadManager.getInstance().init(getApplicationContext(), downloadConfiguration);

i'll make sure if its works without bugs

pishguy commented 7 years ago

@Demuss did you make it?