Lanzr

loop_player,lua

Oct 23rd, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local dfpwm = require("cc.audio.dfpwm")
  2. local speaker = peripheral.find("speaker")
  3.  
  4. local decoder = dfpwm.make_decoder()
  5. while 1 do
  6. local data = http.get(arg[1], nil , true)
  7. -- for
  8. local info = data
  9. filename = "data"
  10.  
  11. while 1 do
  12.     local cksize = 16*1024
  13.     local chunk = data.read(cksize)
  14.  
  15.     local decoded = decoder(chunk)
  16.     while not speaker.playAudio(decoded) do
  17.         os.pullEvent("speaker_audio_empty")
  18.     end
  19.     if(string.len(chunk) < cksize ) then
  20. --        file.close()
  21.         break
  22.     end
  23. end
  24. end
Add Comment
Please, Sign In to add comment