You are not logged in.

1

Monday, January 6th 2020, 6:46pm

loadedbytes action is showing incorrect value

When I call the loadedbytes value for a small video (under ~10mb), it returns the same value as the totalbytes action which means that the video should be completely loaded.


But when I check the network console on Chrome, it shows that the video is still being downloaded from the source. Does anyone know why krpano says the video is completely loaded?

2

Monday, January 6th 2020, 7:28pm

this is not a problem of krpano, you cant get an exact value.

i gave up on loading bars long ago *unsure*

3

Monday, January 6th 2020, 9:16pm

this is not a problem of krpano, you cant get an exact value.

i gave up on loading bars long ago *unsure*
I am able to accurately track the loadedbytes for larger video files, so is this only an issue for small video files?

4

Tuesday, January 7th 2020, 11:13am

because the browers do not give accurate feedback...
there is no loop, reporting you every byte... the data more or less come in chunks.
also with large files the info is not exact i think, but there you get more steps and it seems/probably is more accurate.
if you really need an exact loader you have to do it yourself in js, i guess (preload the file)

5

Wednesday, January 8th 2020, 5:57pm

if you really need an exact loader you have to do it yourself in js, i guess (preload the file)
How would you do that? The best way would be to add a "progress" event listener to the request that is loading the video, but it does not seem like we have access to that part of the code...

Would just need to add something like this...


Source code

1
2
3
4
5
6
7
8
9
10
var req = new XMLHttpRequest();
req.addEventListener('progress', function(event) { 
	if (event.lengthComputable) { 
		var percentComplete = (event.loaded / event.total) * 100; 
		console.log(percentComplete.toFixed(2)); 
		if(percentComplete === 100) { 
			console.log('Loading Complete'); 
		}	
	}
}, false);

6

Wednesday, January 8th 2020, 7:37pm

what i do is simply :
if the video is not loaded / ready in 1-2s then i display a loader animation (spinning circles)
onloaded it hides again
:)

7

Wednesday, January 8th 2020, 7:45pm

Ah, yes that is what I have currently as well for the initial load.

However, I am asking about the incorrect loadedbytes values because I am trying to create a speed test that upgrades/downgrades resolutions depending on the user's network speeds. Whenever the lower qualities are played (360 and 480), krpano believes the video is completely loaded, and therefore I am unable to calculate the buffering rate of the video.