diff --git a/CloudServer/server.js b/CloudServer/server.js index 7751395..18bad8c 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -2027,18 +2027,21 @@ function handleTrainApproaching(ws, data) { const audioId = `approaching-${stationCode}-${Date.now()}`; const built = buildSequenceWavFile(seq); if (built) { + log('INFO', `Pre-arrival audio queued for ${stationName}: ${audioId} (${built.durationSec.toFixed(2)}s)`); enqueueStationAudioTask(stationName, ws, { audioFormat: built.audioFormat, sourcePath: built.sourcePath, streamUrl: built.streamUrl, durationSec: built.durationSec, - priority: 0, - interruptMode: 'none', + priority: 1, + interruptMode: 'ifLower', source: 'train_approaching', audioId, consoleStreamStart: { type: 'stream_start', station: stationName, seq, streamName: getStationStreamName(stationName), hlsUrl: getStationHlsUrl(getStationStreamName(stationName)) }, consoleStreamEnd: { type: 'stream_end', station: stationName } }); + } else { + log('WARN', `Pre-arrival audio build returned empty for ${stationName}: ${audioId}`); } } diff --git a/station_broadcast.lua b/station_broadcast.lua index 05a3de7..bbf48bc 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.47" +local APP_VERSION_TEXT = "v1.0.48" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -2774,22 +2774,27 @@ function Main.loop() end if tName and etaStr then - local announceKey = tName .. "_" .. dest + local announceKey = normalizeUpcomingKey(tName, dest) local etaSeconds = -1 - local isNow = string.find(etaStr, "现在") or string.find(etaStr, "0") + local isNow = string.find(etaStr, "现在") if isNow then etaSeconds = 0 else - local num, unit = string.match(etaStr, "(%d+)%s*(.*)") - if num then - num = tonumber(num) + local mm, ss = string.match(etaStr, "^(%d+)%s*:%s*(%d+)%s*$") + if mm and ss then + etaSeconds = tonumber(mm) * 60 + tonumber(ss) + else + local num, unit = string.match(etaStr, "(%d+)%s*(.*)") + if num then + num = tonumber(num) - if string.find(unit, "秒") or string.find(unit, "s") or string.find(unit, "sec") or (unit == "??" and num > 10) then - etaSeconds = num - else - etaSeconds = num * 60 + if string.find(unit, "秒") or string.find(unit, "s") or string.find(unit, "sec") or (unit == "??" and num > 10) then + etaSeconds = num + else + etaSeconds = num * 60 + end end end end