video download problem on android

I did an app that downloads and plays videoes. It works perfectly well on IOS, but on android it crashes all the time. The code basicly looks something like this:

[lua] local file = “movie.mp4”
local play, download

download = function()

local function networkListener( event )

if ( event.isError ) then
– download error alert
else
timer.performWithDelay ( 1000, play )
end
end

network.download( “http://www.shakebrowser.com/movies/”…file, “GET”, networkListener, file, system.DocumentsDirectory )
end

play = function()

local path = system.pathForFile( file, system.DocumentsDirectory )

if io.open( path ) then
media.playVideo( file, system.DocumentsDirectory, true )
else
download()
end

end

play()[/lua]

As you can see it checks if the video file already exists in the system.DocumentsDirectory if it does it plays the video and if not it downloads the video and plays it afterwards.

My problem is that on android this crashes during download on most of the devices I tested it on so
my question is: is there a limit to the size of the file i download with network.download. Can the crash be caused by the ram being filled during download.

The video is approximately 20 mb and I discovered that if I compress it to below 10 mb it is more likely to work.

Any suggestions is much appreciated [import]uid: 13632 topic_id: 15436 reply_id: 315436[/import]

Hi again.

Can someone please tell me if the network.download downloads the file to ram before writing it to disc? This puts a big limit to the size of files we can download.

Thanks [import]uid: 13632 topic_id: 15436 reply_id: 57561[/import]