forked from hkc/cc-stuff
Streamed player
This commit is contained in:
parent
b051d36bc0
commit
6b250113be
14
stream.lua
14
stream.lua
|
@ -1,5 +1,6 @@
|
|||
local args = { ... }
|
||||
|
||||
local dfpwm = require("cc.audio.dfpwm")
|
||||
local buffer_size = 8192
|
||||
|
||||
if not http then
|
||||
|
@ -26,15 +27,20 @@ for i = 1, buffer_size do
|
|||
buffer[i] = 0
|
||||
end
|
||||
|
||||
local decoder = dfpwm.make_decoder()
|
||||
while true do
|
||||
local chunk = req.read(buffer_size)
|
||||
if not chunk then
|
||||
break
|
||||
end
|
||||
buffer = {}
|
||||
for i = 1, #chunk do
|
||||
buffer[i] = string.byte(chunk, i) - 128
|
||||
end
|
||||
|
||||
--local buffer = {}
|
||||
--for i = 1, #chunk do
|
||||
-- buffer[i] = string.byte(chunk, i) - 128
|
||||
--end
|
||||
|
||||
local buffer = decoder.decode(chunk)
|
||||
|
||||
while not speaker.playAudio(buffer) do
|
||||
os.pullEvent("speaker_audio_empty")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue