From 6c965525e433f55b1fe364fb59a9ee2b8843dac9 Mon Sep 17 00:00:00 2001 From: xingluo Date: Sat, 10 Jan 2026 02:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20play.lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- play.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/play.lua b/play.lua index 29b8c60..ec594a7 100644 --- a/play.lua +++ b/play.lua @@ -168,7 +168,7 @@ end -- 分批下载(每批 50 帧) local BATCH_SIZE = 20 -- local totalFrames = #videoInfo.frame_urls -local totalFrames = videoInfo.fps * 10 -- 仅下载前10秒以节省时间 +local totalFrames = videoInfo.fps * 5 -- 仅下载前5秒以节省时间 local allFrameData = {} for startIdx = 1, totalFrames, BATCH_SIZE do @@ -256,7 +256,7 @@ sleep(1) -- 播放前已缓存 10 秒 local totalFramesToPlay = #videoInfo.frame_urls local maxCachedFrames = math.min(videoInfo.fps * 20, totalFramesToPlay) -- 最多缓存 20 秒 -local nextDownloadIndex = math.min(videoInfo.fps * 10 + 1, totalFramesToPlay + 1) -- 从第 10 秒后开始继续下载 +local nextDownloadIndex = math.min(videoInfo.fps * 5 + 1, totalFramesToPlay + 1) -- 从第 5 秒后开始继续下载 -- 标志:是否还在播放 local running = true @@ -360,14 +360,14 @@ local function cacheAhead() end end --- 音频播放协程(保持原样) -local function playAudio() - os.queueEvent("audio_start") -- 触发同步 - shell.run("bg speakerlib play " .. - server_url .. videoInfo.audio_dfpwm_url .. " " .. - server_url .. videoInfo.audio_dfpwm_left_url .. " " .. - server_url .. videoInfo.audio_dfpwm_right_url) -end +-- -- 音频播放协程(保持原样) +-- local function playAudio() +-- os.queueEvent("audio_start") -- 触发同步 +-- shell.run("bg speakerlib play " .. +-- server_url .. videoInfo.audio_dfpwm_url .. " " .. +-- server_url .. videoInfo.audio_dfpwm_left_url .. " " .. +-- server_url .. videoInfo.audio_dfpwm_right_url) +-- end -- 视频渲染协程(稍作优化:及时清理旧帧) local function renderVideo() @@ -455,7 +455,7 @@ end -- 启动三个协程 -parallel.waitForAll(renderVideo, playAudio, cacheAhead) +parallel.waitForAll(renderVideo, cacheAhead) local endtime = os.clock() local time = endtime-starttime1