--!movie
--!encoding=utf-8
global $
global gCh
----------------------------------------
-- Download file with ftp (asynchronous/non-blocking mode)
-- Show progress info
----------------------------------------
on startMovie
_player.debugPlaybackEnabled = 1
-- libs
$.import("curl")
-- config
tRemoteFile = "ftp://ftp.fu-berlin.de/pub/du-k.gz"
tLocalFile = $.PATH & "du-k.gz"
-- get a CURL handle (xtra instance)
gCh = $.curl.init()
-- specify options
gCh.setOption($.curl.CURLOPT.URL, tRemoteFile)
--gCh.setOption($.curl.CURLOPT.USERNAME, tUsername)
--gCh.setOption($.curl.CURLOPT.PASSWORD, tPassword)
gCh.setOption($.curl.CURLOPT.NOPROGRESS, 0)
gCh.setDestinationFile(tLocalFile)
gCh.setProgressCallback(#slotCurlProgress)
$.curl.execAsyncDetached(gCh, #slotCurlResult)
end
----------------------------------------
-- @callback
----------------------------------------
on slotCurlResult (res)
put "DOWNLOAD FINISHED!"
put "ERROR:" && curl_error(res) -- if returnMode=0, res is ALWAYS an error code
--put "SPEED_DOWNLOAD:" && gCh.getInfo($.curl.CURLINFO.SPEED_DOWNLOAD)
--put "TOTAL_TIME:" && gCh.getInfo($.curl.CURLINFO.TOTAL_TIME)
gCh = VOID
end
----------------------------------------
-- @callback
----------------------------------------
on slotCurlProgress (dltotal, dlnow, ultotal, ulnow)
--put dltotal, dlnow, ultotal, ulnow
if dltotal>0 then
put (dlnow*100/dltotal) && "%"
end if
end