Skip to content
This repository was archived by the owner on May 7, 2023. It is now read-only.
Sébastiaan edited this page Oct 8, 2017 · 2 revisions

How does it work?

  1. Add the torrent file or magnet link to the libtorrent session and select the largest file as only download. Also calculated the amount of pieces that need to be downloaded before the stream is marked as 'ready'.
    TorrentStream.java#L83
  2. Prioritise the first and last pieces of the selected file using the previously calculated amount of pieces. This should result in:
    ++----------------------++
    Torrent.java#L264
  3. Once the prioritised pieces are downloaded set the download to sequential. Either using the sequential mode in libtorrent or sequential downloading in TorrentStream depending on the knowledge we have of the pieces.
    Torrent.java#L457
    Torrent.java#L401
  4. Profit
    +++---------------------++
    ++++--------------------++
    +++++-------------------++

Why won't my video player open the file/stream?

It does happen that a video player doesn't really like the incomplete file. The only ones that have worked during testing are VLC, ExoPlayer and MX Player. ijkplayer may also work but that has not been confirmed.

Does this support seeking through the video?

No, and yes. Opening the video in a normal video player won't allow you to seek. This will need some more work and you'll have to decide what you think is the best solution. TorrentStream allows you to 'seek' by using setInterestedBytes(int) on the Torrent object. This will calculate the pieces that are needed for that certain byte in the video file. This is how TorrentStreamServer-Android works. That library turns the video file into a 'real' HTTP stream that may work better due to the way partial content is handled using the TorrentInputStream.

Clone this wiki locally