mp3 - Loading audio file from an URL in Lua -
i need load mp3 file url in lua.
i've tried doesn't work.
require "socket.http" local resp, stat, hdr = socket.http.request{ url = "https://www.dropbox.com/s/hfrdbncfgbsarou/hello.mp3?dl=1", } local audiofile = audio.loadsound(resp) audio.play(audiofile)
any ideas?
the request
function "overloaded" (in terminology of other languages). detailed in documentation, has 3 signatures:
local responsebodystring, statusnumber, headertable, statusstring = request( urlstring ) -- local responsebodystring, statusnumber, headertable, statusstring = request( urlstring, requestbodystring ) -- post local success, statusnumber, headertable, statusstring = request( requestparametertable ) -- depends on parameters
see documentation details, concerning error results.
for last form, lua syntax allow function called table constructor instead of single table parameter in parentheses. that's form , syntax using. but, incorrectly expect first return value response body. response body passed "sink" function optionally indicated in request parameter table, don't have.
try first form:
local resp, stat, hdr = socket.http.request("https://www.dropbox.com/s/hfrdbncfgbsarou/hello.mp3?dl=1")
Comments
Post a Comment