network.download temporary file name

hey folks,

I try to download a sound-file from my server and play it while it is still loading… so far so good but the filename is a different and temporary one as I could see in my sandbox so I can not open it. any idea how to solve this?

code’s like that:

 local function networkListener( event ) if ( event.isError ) then print( "Network error - download failed" ) elseif ( event.phase == "began" ) then print( "Progress Phase: began" ) elseif ( event.phase == "progress" ) then for k,v in pairs(event) do --print (k,v) end local bTransferred = event.bytesTransferred local bEstimated = event.bytesEstimated print(event.bytesTransferred, event.bytesEstimated) if bTransferred \>= bEstimated / 2 then backgroundMusic = audio.loadStream('test.m4a', system.TemporaryDirectory) backgroundMusicChannel = audio.play( backgroundMusic, { channel=1, loops=-1, fadein=5000 } ) end elseif ( event.phase == "ended" ) then end end local params = {} params.progress = true network.download( "http://somewhere.com/test.m4a", "GET", networkListener, params, "test.m4a", system.TemporaryDirectory )

best regards,

roman

I just realized that it doesn’t work even now that I’ve figured out what the temporary file name is, it just doesn’t play it (probably because there’s so suffix to it). it’s a real pity that audio streaming is not supported!

audio.loadStream() is just for loading already existing, downloaded files.  It will not play the file until it is completely downloaded.  Steam is somewhat confusing.  For complete files, audio.loadSound() will completely load the file in memory, decode the entire file, then start playing it.  For longer sounds (over a few seconds), it can slow your program down too much while the whole file is loaded in, so it will start playing it before it completes loading.   So it acts like streaming, but only with local files.

The tmp file name you are seeing is what network.download is writing too.  Likely when it completes the tmp file will be removed and the whole file ends up in the folder you downloaded it to. 

I just realized that it doesn’t work even now that I’ve figured out what the temporary file name is, it just doesn’t play it (probably because there’s so suffix to it). it’s a real pity that audio streaming is not supported!

audio.loadStream() is just for loading already existing, downloaded files.  It will not play the file until it is completely downloaded.  Steam is somewhat confusing.  For complete files, audio.loadSound() will completely load the file in memory, decode the entire file, then start playing it.  For longer sounds (over a few seconds), it can slow your program down too much while the whole file is loaded in, so it will start playing it before it completes loading.   So it acts like streaming, but only with local files.

The tmp file name you are seeing is what network.download is writing too.  Likely when it completes the tmp file will be removed and the whole file ends up in the folder you downloaded it to.