--!movie
--!encoding=utf-8
global $
----------------------------------------
-- Download a file with http get (synchronous/blocking mode)
----------------------------------------
on startMovie
_player.debugPlaybackEnabled = 1
-- libs
$.import("curl")
-- get a CURL handle (xtra instance)
ch = $.curl.init()
-- specify options
ch.setOption($.curl.CURLOPT.URL, "http://valentin.dasdeck.com/xtras/curl_xtra/.test/test.mp3")
-- specify target filename
ch.setDestinationFile($.PATH & "downloaded.mp3")
-- returnMode: 0=return error code (=default), 1=return data
-- => has to be 0 (or void) to download as file!
res = ch.exec()
put "ERROR:" && curl_error(res)
-- put "SPEED_DOWNLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_DOWNLOAD)
-- put "TOTAL_TIME:" && ch.getInfo($.curl.CURLINFO.TOTAL_TIME)
end