Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
UrlLoader onProgress is called only when the file is downloaded completely? — Gideros Forum

UrlLoader onProgress is called only when the file is downloaded completely?

bysregbysreg Member
edited January 2014 in General questions
here is my code:
function XX:getFile(asset, path)
		self.loader = UrlLoader.new( path..asset )
 
	local function onComplete(event)
		local out = io.open( "|D|"..asset, "wb" )
		out:write( event.data )
		out:close()
	end
 
	local function onError()
		// bla bla
	end
 
	local function onProgress(event)
		print("progress: ", event.bytesLoaded, " of ", event.bytesTotal)
	end
 
	self.loader:addEventListener(Event.COMPLETE, onComplete)
	self.loader:addEventListener(Event.ERROR, onError)
	self.loader:addEventListener(Event.PROGRESS, onProgress)
end
From my test, It seems when urlloader is downloading large file, the onProgress calls are only called when the file is already completed.

example output :

d ( DownloadData ) : timeout remaining 119000 ms
// ... skipped
d ( DownloadData ) : timeout remaining 87000 ms
// i stopped checking for timeout when onProgress was called for the first time
d ( FileLoader ) : progress: 98304 of 544466 . time remaining: 87000
d ( FileLoader ) : progress: 114688 of 544466 . time remaining: 120000
d ( FileLoader ) : progress: 122880 of 544466 . time remaining: 120000
// ... skipped
d ( FileLoader ) : progress: 540672 of 544466 . time remaining: 120000
d ( FileLoader ) : progress: 544466 of 544466 . time remaining: 120000
// ... I also kept tracking for timeout between onProgress. You can see that after the first time onProgress is called, the next onProgress calls happened in an instant.

Comments

Sign In or Register to comment.