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