Download and play video

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

network.download( “http://lamp.t-c.gr/puma/video.mov”, “GET”, networkListener, “video.mov”, system.ResourceDirectory ) [import]uid: 4416 topic_id: 6668 reply_id: 306668[/import]

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

[import]uid: 6459 topic_id: 6668 reply_id: 23269[/import]

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]

abinop,

system.DocumentsDirectory didn’t work for me either.
[import]uid: 13125 topic_id: 6668 reply_id: 25576[/import]

iOS? Android?

Does the mov play if you were to put it in an app by itself before downloading it? (pre-install it on a test app) and see if it plays.

How bout firing an event when the download finishes to give time for any files to flush? and then play the movie?

C. [import]uid: 24 topic_id: 6668 reply_id: 25587[/import]

i am using iOS

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 ?

thank’s
[import]uid: 13125 topic_id: 6668 reply_id: 25620[/import]

did you have a look at this tutorial?

cu
t
[import]uid: 10834 topic_id: 6668 reply_id: 28399[/import]