I am trying to download remotely a video file and then play it locally. The code I am using is the following. The file is downloaded but it does not load the video (without showing any error messages however). I tried it on the device, not only the simulator.
Following is the code I am using:
local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
else
local path = system.pathForFile( “video.mov”, system.ResourceDirectory )
local t1 = display.newText( “downloaded”, 0, 250, nil, 8);
media.playVideo( path )
end
local t1 = display.newText( "RESPONSE: " … event.response, 0, 20, nil, 8);
end
you cannot download the file to the ResourceDirectory, because Apple will reject your app.
you are not allowed to make changes to the file system of the resource directory.
“you should never create, modify, or add files to this directory” from Corona documentation
use the system.DocumentsDirectory or system.TemporaryDirectory to download files
tetu,
I have tried using DocumentsDirectory and still the video does not play on the device.
Do you have any idea why this may happen? Does the code work for you? [import]uid: 4416 topic_id: 6668 reply_id: 23281[/import]
if i pre-install it, it works, i can display movie
i did check for it to finished downloading , but not sure if it is long enough.
How do you flush the files by the way ?