更新 speakerlib.lua

This commit is contained in:
2026-01-26 19:17:00 +08:00
parent c88b54af6c
commit 147a80e979

View File

@@ -88,7 +88,7 @@ end
local function get_total_duration(url) local function get_total_duration(url)
if _G.Playprint then printlog("Calculating duration...") end if _G.Playprint then printlog("Calculating duration...") end
local handle, err = http.get(url) local handle, err = http.get(url,{["Content-Type"] = "application/json"}, true)
if not handle then if not handle then
error("Could not get duration: " .. (err or "Unknown error")) error("Could not get duration: " .. (err or "Unknown error"))
end end
@@ -194,21 +194,21 @@ elseif cmd == "play" then
-- 创建HTTP连接 -- 创建HTTP连接
if main_dfpwm_url then if main_dfpwm_url then
main_httpfile = http.get(main_dfpwm_url) main_httpfile = http.get(main_dfpwm_url,{["Content-Type"] = "application/json"}, true)
if not main_httpfile then if not main_httpfile then
error("Could not open main audio stream") error("Could not open main audio stream")
end end
end end
if left_dfpwm_url then if left_dfpwm_url then
left_httpfile = http.get(left_dfpwm_url) left_httpfile = http.get(left_dfpwm_url,{["Content-Type"] = "application/json"}, true)
if not left_httpfile then if not left_httpfile then
error("Could not open left audio stream") error("Could not open left audio stream")
end end
end end
if right_dfpwm_url then if right_dfpwm_url then
right_httpfile = http.get(right_dfpwm_url) right_httpfile = http.get(right_dfpwm_url,{["Content-Type"] = "application/json"}, true)
if not right_httpfile then if not right_httpfile then
error("Could not open right audio stream") error("Could not open right audio stream")
end end
@@ -252,17 +252,17 @@ elseif cmd == "play" then
if right_httpfile then right_httpfile.close() end if right_httpfile then right_httpfile.close() end
if main_dfpwm_url then if main_dfpwm_url then
main_httpfile = http.get(main_dfpwm_url) main_httpfile = http.get(main_dfpwm_url,{["Content-Type"] = "application/json"}, true)
if not main_httpfile then error("Could not reopen main stream") end if not main_httpfile then error("Could not reopen main stream") end
end end
if left_dfpwm_url then if left_dfpwm_url then
left_httpfile = http.get(left_dfpwm_url) left_httpfile = http.get(left_dfpwm_url,{["Content-Type"] = "application/json"}, true)
if not left_httpfile then error("Could not reopen left stream") end if not left_httpfile then error("Could not reopen left stream") end
end end
if right_dfpwm_url then if right_dfpwm_url then
right_httpfile = http.get(right_dfpwm_url) right_httpfile = http.get(right_dfpwm_url,{["Content-Type"] = "application/json"}, true)
if not right_httpfile then error("Could not reopen right stream") end if not right_httpfile then error("Could not reopen right stream") end
end end