Hi,
calculating the download progress is a little bit complicated at the moment,
because of the multi-resolution loading it's difficult to show a correct progress.
have a look at the "krpano.progress.*" values here:
http://krpano.com/docu/api/
here a quick explanation of these values:
progress.loaddone
- while loading "false", when done "true"
progress.bytesloaded
- sum of bytes from all files that are current downloading
(see the value set in "network.downloadqueues" for how many files are
max. loading at the same time, if you set it to 1 it would be a little
bit easier to calculate a good progress value)
progress.bytestotal
- sum of all total bytes from all files that are current downloading
progress.filesloaded
- number of files are already downloaded (for the current level)
progress.filestotal
- total files (for the current level)
progress.filesneeded
- files that are needed to be downloaded for the current view
progress.decodesneeded
- each image must also be decoded
- this is the number of files that needed to be decoded for the current view
from these values the current progress can be calculated,
this is my current implementation in the viewer: (not optimal)
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// because the current number of files that are needed
// is changing very fast, I save the latest maxium of the
// filesneeded value:
public var lastmax_filesneeded:int = 0; // global or static var!
// now here the code that draws a progress bar or something else:
// call it in a enterframe or timer loop:
if (krpano.get("progress.loaddone") != "true")
{
bytesloaded = int( krpano.get("progress.bytesloaded") );
bytestotal = int( krpano.get("progress.bytestotal") );
var bytes_progress:Number = 0.0;
if (bytestotal > 0)
{
bytes_progress = Number(bytesloaded+1) / bytestotal;
}
var filestotal :int = int( krpano.get("progress.filestotal") );
var filesneeded :int = int( krpano.get("progress.filesneeded") );
if (filesneeded > lastmax_filesneeded)
{
lastmax_filesneeded = filesneeded;
}
else if (filesneeded == 0)
{
lastmax_filesneeded = 0;
}
if (filestotal > 0)
{
progress = 1.0;
}
if (lastmax_filesneeded > 0)
{
progress = 1.0 - Number(filesneeded-1 + (1.0 -
bytes_progress))/lastmax_filesneeded;
}
// now draw a progress bar - the progress value is now between 0.0 and 1.0
}
|
but note - this is not a really good algorithm at the moment

it will be improved next,
best regards,
Klaus