@totorofat Here’s a version I threw together that lets you have a button for multiple mp3 files. You can tap all the buttons for what you want to download. It shows the names that are waiting to downloaded and also the file that is being downloaded. I don’t know if you’re after something like this or not so I didn’t put a lot of time into it. I just picked 5 small mp3 files to test.
EDIT: Itsaves the mo3 Files in the Dropbox folder with the names you setup in the nameTable.
supportedOrientations(LANDSCAPE_ANY)
function setup()
rectMode(CENTER)
-- table of mp3 files
tuneTable={
"http://www.amigaremix.com/files/2894/laki_-_Shadow_of_the_Beast_-_Death_Scene.mp3",
"http://www.amigaremix.com/files/2910/EXON_-_Lotus_III_Theme_.mp3",
"http://www.amigaremix.com/files/2869/Darkman007_-_Dazzler_Cover.mp3",
"http://www.amigaremix.com/files/2212/Cisskey_-_Turrican_2_-_In_the_water.mp3",
"http://www.amigaremix.com/files/2010/Sven_Storm_-_Firehawk_Loader.mp3" }
-- table of names that will be saved for the mp3 files
nameTable={"Death_Scene","Lotus_III_Theme","Dazzler_Cover","In_the_water","Firehawk_Loader" }
queTable={} -- table of mp3 files waiting to download
end
function draw()
background(40, 40, 50)
if #queTable>0 then
if not downloading then
pos=queTable[1]
tune=tuneTable[pos]
loadMusic()
end
end
fill(255)
text("Selection",100,HEIGHT-20)
for a,b in pairs(nameTable) do
fill(255)
rect(100,HEIGHT-60*a,200,50)
fill(255,0,0)
text(b,100,HEIGHT-60*a)
end
fill(255)
text("To download",400,HEIGHT-20)
for a,b in pairs(queTable) do
text(nameTable[b],400,HEIGHT-50*a)
end
if #queTable>0 then
text("Downloading -- "..nameTable[pos],WIDTH/2,200)
end
end
function touched(t)
if t.state==BEGAN then
for z=1,#tuneTable do
if t.x>0 and t.x<200 and
t.y>HEIGHT-60*z-25 and t.y<HEIGHT-60*z+25 then
table.insert(queTable,z)
end
end
end
end
function loadMusic()
downloading=true
http.request(tune,didLoadMusic)
end
function didLoadMusic(data,status,headers)
writeFile(nameTable[pos]..".mp3",data)
downloading=false
table.remove(queTable,1)
end
function writeFile(fileName, data)
local file = os.getenv("HOME").."/Documents/Dropbox.assets/"..fileName --ok
wFd, err = io.open(file, "w")
if wFd == nil then
error("\
\
Error creating file " .. fileName .. "\
\
Error: " .. err)
end
wFd:write(data)
wFd:close()
end