Track progress for currently playing file. Fixes #244

This commit is contained in:
DC
2016-03-27 16:16:38 -07:00
parent a2ee63023f
commit 86309317a7

View File

@@ -266,15 +266,16 @@ function renderLoadingBar (state) {
if (torrent === null) { if (torrent === null) {
return [] return []
} }
var file = torrent.files[state.playing.fileIndex]
// Find all contiguous parts of the torrent which are loaded // Find all contiguous parts of the torrent which are loaded
var parts = [] var parts = []
var lastPartPresent = false var lastPartPresent = false
var numParts = torrent.pieces.length var numParts = file._endPiece - file._startPiece + 1
for (var i = 0; i < numParts; i++) { for (var i = file._startPiece; i <= file._endPiece; i++) {
var partPresent = torrent.bitfield.get(i) var partPresent = torrent.bitfield.get(i)
if (partPresent && !lastPartPresent) { if (partPresent && !lastPartPresent) {
parts.push({start: i, count: 1}) parts.push({start: i - file._startPiece, count: 1})
} else if (partPresent) { } else if (partPresent) {
parts[parts.length - 1].count++ parts[parts.length - 1].count++
} }