local verson = "2.6" shell.run("label set \"DFPWM Player v"..verson.."\"") local basalt = require("basalt") local debugm = false local password = "!Comp" basalt.onEvent(function(event) if(event=="terminate")then if not debugm then return false end end end) local first = true local music = fs.list("/Music/") local mainFrame = basalt.createFrame() local aLabel = mainFrame:addLabel():setText("DFPWM P ayer v"..verson.."") local bLabel = mainFrame:addLabel():setText("Made w love by Johncomp") :setPosition(1, 2) local aList = mainFrame:addList():setScrollable(true) :setSize(17,16) :setPosition(1, 4) local sList = mainFrame:addList():setScrollable(true):hide() :setSize(17,6) :setPosition(1, 14) local unhidein = mainFrame:addButton():setPosition(8,1):setSize(1,1):setText("l"):setBackground(colors.lightgray) local input = mainFrame:addInput():setInputType("password"):setPosition(17,1):setSize(8,1):setBackground(colors.red):hide() local submit = mainFrame:addButton():setPosition(7,2):setSize(1,1):setText("/"):setBackground(colors.lightgray) unhidein:onClick(basalt.schedule(function() input:show() end)) submit:onClick(basalt.schedule(function() if(password==input:getValue())then basalt.debug("Unlocked!") debugm = true else end end)) local aProgram = mainFrame:addProgram():hide() :setSize(26,4) :setPosition(1, 2) local songs local actart aList:addItem("1") local pause = mainFrame:addButton():setText(" Pause"):onClick(function() aProgram:pause(true) unhidein:hide() aLabel:setText("Paused -") end):hide() :setPosition(19, 7) :setSize(7,3) local resume = mainFrame:addButton():setText(" Play "):onClick(function() aProgram:pause(false) unhidein:hide() aLabel:setText("Playing -") end):hide() :setPosition(19, 14) :setSize(7,3) function debounce(func, wait) local last = 0 return function(...) local now = os.clock() if now - last >= wait then last = now return func(...) end end end function listSongs() for i,v in ipairs(songs) do local t2 = sList:addItem(""..v.."") end end function buttonOnClick(button, index) if debugm then basalt.debug("Button", index, " clicked!") end if first then first = false aList:setSize(17,9) end sList:show() songs = fs.list("/Music/"..index.."") sList:clear() sList:addItem("1") listSongs() sList:removeItem(1) actart = index end function buttonPlaysong(button, indexx) -- songs = fs.list("/Music/"..actart.."/"..indexx.."") if debugm then basalt.debug("/Music/"..actart.."/"..indexx.."") end aLabel:setText("Now Playing -") resume:show() pause:show() aList:setPosition(1, 7) aList:setSize(17,6) sList:setPosition(1, 14) aProgram:show() aProgram:execute("Music/"..actart.."/"..indexx.."") end local debouncedButtonOnClick = debounce(buttonOnClick, 0.05) local debouncedButtonOnClick2 = debounce(buttonPlaysong, 0.05) aList:onChange(function() local index = aList:getItemIndex() debouncedButtonOnClick(button, aList:getValue().text) end) sList:onChange(function() local index = sList:getItemIndex() debouncedButtonOnClick2(button, sList:getValue().text) end) function listMusic() for i,v in ipairs(music) do local t1 = aList:addItem(""..v.."") end end aProgram:onDone(function() aLabel:setText("DFPWM P ayer v"..verson.."") unhidein:show() resume:hide() pause:hide() aProgram:hide() sList:clear() sList:addItem("1") listSongs() sList:removeItem(1) aList:setPosition(1, 4) aList:setSize(17,9) sList:setPosition(1, 14) end) listMusic() aList:removeItem(1) basalt.autoUpdate()