Schneemann

dfpwm music player

Sep 26th, 2021 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. songs = {
  2. ["1"] = {["name"] = "Handlebars", ["author"] = "Flobots", ["url"] = "https://drive.google.com/uc?export=download&id=1VXcxKPin71p6UWQcz3wJEyU9ErIqaTp6"},
  3. ["2"] = {["name"] = "Island In The Sun", ["author"] = "Weezer", ["url"] = "https://drive.google.com/uc?export=download&id=1E2m0e4iM56Bt_ntzqw7aKHzqZ1YLF07W"}
  4. }
  5.  
  6. function writeToTape(url)
  7. tape = peripheral.find("tape_drive")
  8.  
  9. local response = http.get(url, nil, true) -- THIS IS IMPORTANT
  10.  
  11. tape.seek(-tape.getPosition()) --Rewind to start
  12. tape.write(response.readAll())
  13. response.close()
  14.  
  15. tape.seek(-tape.getPosition())
  16. end
  17.  
  18. function play(songID)
  19. writeToTape(songs[songID])
  20. tape.play()
  21. end
Add Comment
Please, Sign In to add comment