Question

I'm working on an app that requires downloading of big video files (300-500MB).
I would like to know if there's a way to speed up the download of a single file using multi-threading.
I've saw this type of implementation on applications like TubeMate, but I clueless about the code used to achieve it.
I don't need you to code for me :) I just need a starting point, like an article or tutorial about this, tks.

No correct solution

OTHER TIPS

Video can be represented as byte array. If you want to load array faster you can divide it in parts and load every part in separate thread. The best way to do that is using ThreadPoolExecutor to run the task and FutureTask to retrieve results. In case you need to dawnload video from the internet, your server should support api calls that can give you "part" of video. Here is the good sample of how to use Executors and Futures: https://www.journaldev.com/1650/java-futuretask-example-program

Regardless of finding a library function, you could also make your own script to handle partial downloads.

For example, in PHP, you can use the fopen(), fread()... functions to open a stream on the server, seek the file to a particular position and transmit bytes to the requester. File offset and chunk length parameters would be set by the client using POST or GET methods.

Check this link. Maybe it helps you a little bit.

If, on the other hand, you don't have access to the server, and you just want to improve downloads from any Internet site, then you could look up for HTTP range header or here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top