Streamed player

This commit is contained in:
Casey 2023-12-18 18:23:11 +03:00
parent b051d36bc0
commit 6b250113be
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 10 additions and 4 deletions

View File

@ -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