1. --!movie
  2. --!encoding=utf-8
  3.  
  4. global $
  5.  
  6. ----------------------------------------
  7. -- Download a file via HTTPS (asynchronous/non-blocking mode)
  8. ----------------------------------------
  9. on startMovie
  10.     _player.debugPlaybackEnabled = 1
  11.  
  12.     -- libs
  13.     $.import("curl")
  14.  
  15.     -- get a CURL handle (xtra instance)
  16.     ch = $.curl.init()
  17.  
  18.     -- specify options
  19.     ch.setOption($.curl.CURLOPT.URL, "https://valentin.dasdeck.com/xtras/curl_xtra/.test/test.mp3")
  20.     ch.setOption($.curl.CURLOPT.SSL_VERIFYPEER, 0)
  21.     ch.setOption($.curl.CURLOPT.NOPROGRESS, 0)
  22.  
  23.     -- specify local download target file
  24.     ch.setDestinationFile($.PATH & "downloaded.mp3")
  25.  
  26.     -- use "detached" callback for progress feedback (allowing full debugging)
  27.     $.curl.setProgressCallbackDetached(ch, #slotCurlProgress)
  28.  
  29.     -- use "detached" callback for final result feedback (allowing full debugging)
  30.     $.curl.execAsyncDetached(ch, #slotCurlResult)
  31. end
  32.  
  33. ----------------------------------------
  34. -- Show download progress in message window
  35. -- @callback
  36. ----------------------------------------
  37. on slotCurlProgress (dltotal, dlnow)
  38.     if dltotal>0 then put (dlnow*100/dltotal) && "%"
  39. end
  40.  
  41. ----------------------------------------
  42. -- Show final result in message window
  43. -- @callback
  44. ----------------------------------------
  45. on slotCurlResult (res)
  46.     put "slotCurlResult", curl_error(res) -- res=0 => "No error"
  47. end
  48.  
[raw code]