1
0
Fork 0

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