Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chan = "Luca radio"
- local handle = http.get("http://localhost/cc/list.php")
- local songs = {}
- local line = ""
- while line ~= nil do
- line = handle.readLine()
- table.insert(songs,line)
- end
- handle.close()
- os.loadAPI("note")
- local t = peripheral.find("bitnet_tower") -- looks for tower instead
- local function radioPlay()
- while true do
- for k,v in pairs(songs) do
- print("Playing "..v)
- local handle = http.get("http://localhost/cc/sound/" .. v:gsub(" ","%%20"))
- local handle2 = fs.open(".temp", "w")
- handle2.write(handle.readAll()) handle.close() handle2.close()
- song = note.readNbs(".temp")
- fs.delete(".temp")
- if not song.name or song.name == "" then
- song.name = v:sub(1,#v-4)
- end
- notes = song.notes
- if notes == "" then
- v:gsub("_"," ")
- end
- len = math.floor(song.length/song.tempo)
- cur = 0
- while cur <= song.length do
- if notes[cur] then
- sec = math.floor(cur/song.tempo)
- tr = {tMessage={["notes"] = notes[cur], ["all"] = len, ["cur"] = sec,["name"]=song.name},sType="radio",sChannel=chan}
- t.transmit(tr)
- end
- sleep(song.tempo/100)
- cur = cur + 1
- end
- end
- end
- end
- local function skipSong()
- while true do
- local tEvent = {os.pullEvent()}
- if tEvent[1] == "key" and tEvent[2] == keys.space then
- song.length = 0 -- break loop
- print("Skipping current song.")
- end
- end
- end
- parallel.waitForAny(skipSong, radioPlay)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement