I’m wondering how can I retrieve a music file from the internet to use in a game?
I tried something like this but did nothing
http.request("http://www.magicmusicx.com/uploads/4/2/7/2/4272634/16._lovin_on_dire_docks.mp3", function(data, status, headers) music(data) end)
music() doesn’t play MP3s I don’t think. You could try something like saveLocalData(“song”, data), but I don’t know.
@NewToonie Try this code. It will read the file you give in
tune and then save it in the Documents folder as the name you put in
mp3Name. It takes about 22 seconds to download your mp3 file and then will start to play. It’s in the Documents folder where you can use it whenever you want. Remember to change the mp3Name or the file will overwrite a previous file.
-- change mp3Name to what you want, it will be saved in the Documents folder.
-- change tune to the mp3 file you want to download
print("reading mp3 file: "..mp3Name)
function writeFile(fileName, data)
local file = os.getenv("HOME") .. "/Documents/" .. fileName..".mp3"
wFd, err = io.open(file, "w")
if wFd == nil then
Error creating/editing file " .. fileName .. "\
Error: " .. err)
saved in Documents folder.")
@dave1707 Wow it worked! Thanks alot!!