From 6b250113be381e21bfb104043acbb5f62018a69d Mon Sep 17 00:00:00 2001 From: hkc Date: Mon, 18 Dec 2023 18:23:11 +0300 Subject: [PATCH] Streamed player --- stream.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/stream.lua b/stream.lua index 0839fd5..5e0423b 100644 --- a/stream.lua +++ b/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