feat(Player): "loading" status while a melody downloads + playback_failed report (F-068)
A play that needed a download was ACKed SUCCESS and then nothing was
visible until playback started — and a failed download was only logged.
- New PlayerStatus::LOADING: status/playback publishes action "loading"
(pid/speed/duration/source set) before the ACK, then "playing" on success
or "idle" on failure.
- On failure after the ACK, control/reports gets
{ "type": "playback_failed", "payload": { "pid", "reason" } } (and a WS
INFO of the same). The download task re-checks bells-disabled/overload
before playing.
- playback.stop / forceStop during LOADING cancels the pending start
("Download cancelled — playback will not start"); the transfer finishes
and is discarded. New plays are refused until it does, since the task
still owns pid/_melodySteps. A mutex serialises the task's cancel-check +
play() against the cancel path.
- "loading" is MQTT-only: v1 tablets map unknown WS playback actions to
"unavailable" (F-061 symptom). system.status reports LOADING; the v1
adapter maps it to "idle".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,8 +22,10 @@ static bool translateSystemStatus(const CommandResult& result, JsonDocument& out
|
||||
out["type"] = "current_status";
|
||||
JsonObject payload = out["payload"].to<JsonObject>();
|
||||
|
||||
// v2 sends UPPERCASE enum names (PLAYING/PAUSED/STOPPING/STOPPED);
|
||||
// v1 expects lowercase state words, with STOPPED spelled "idle".
|
||||
// v2 sends UPPERCASE enum names (PLAYING/PAUSED/STOPPING/STOPPED/LOADING);
|
||||
// v1 expects lowercase state words, with STOPPED spelled "idle". LOADING
|
||||
// deliberately falls through to "idle" — v1 apps have no loading state and
|
||||
// treat unknown words as "unavailable".
|
||||
const char* v2Status = data["player_status"] | "STOPPED";
|
||||
const char* v1Status = "idle";
|
||||
if (strcmp(v2Status, "PLAYING") == 0) v1Status = "playing";
|
||||
|
||||
@@ -514,6 +514,25 @@ void CommunicationRouter::sendBellOverloadNotification(
|
||||
bellNumbers.size(), severity.c_str());
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Playback failed notification
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
void CommunicationRouter::sendPlaybackFailedNotification(const String& pid, const String& reason) {
|
||||
JsonDocument payload;
|
||||
payload["pid"] = pid;
|
||||
payload["reason"] = reason;
|
||||
|
||||
JsonDocument wsDoc;
|
||||
wsDoc["status"] = "INFO";
|
||||
wsDoc["type"] = "playback_failed";
|
||||
wsDoc["payload"] = payload;
|
||||
broadcastStatus(wsDoc);
|
||||
|
||||
publishReport("playback_failed", payload);
|
||||
LOG_WARNING(TAG, "Playback failed notification sent: %s — %s", pid.c_str(), reason.c_str());
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Alert / Info publishing
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -121,6 +121,15 @@ public:
|
||||
const std::vector<uint16_t>& bellLoads,
|
||||
const String& severity);
|
||||
|
||||
/**
|
||||
* @brief A play command was ACKed SUCCESS ("download started") but playback
|
||||
* never began — download failed, file bad, or blocked by the time it
|
||||
* finished. MQTT: control/reports {"type":"playback_failed","payload":
|
||||
* {"pid","reason"}}. WS: INFO broadcast of the same (v1 tablets ignore
|
||||
* unknown INFO types). Called from the MelodyDL task.
|
||||
*/
|
||||
void sendPlaybackFailedNotification(const String& pid, const String& reason);
|
||||
|
||||
/**
|
||||
* @brief Publish the playback state to vesper/{id}/status/playback (retained, QoS 1).
|
||||
* Called by Player::setStatus() on every transition. WS clients
|
||||
|
||||
@@ -113,6 +113,7 @@ CommandResult SystemHandler::handleStatus(const CommandEnvelope& e) {
|
||||
case PlayerStatus::PLAYING: statusStr = "PLAYING"; break;
|
||||
case PlayerStatus::PAUSED: statusStr = "PAUSED"; break;
|
||||
case PlayerStatus::STOPPING: statusStr = "STOPPING"; break;
|
||||
case PlayerStatus::LOADING: statusStr = "LOADING"; break;
|
||||
default: break;
|
||||
}
|
||||
doc["player_status"] = statusStr;
|
||||
@@ -247,6 +248,7 @@ CommandResult SystemHandler::handleGetAll(const CommandEnvelope& e) {
|
||||
case PlayerStatus::PLAYING: psStr = "PLAYING"; break;
|
||||
case PlayerStatus::PAUSED: psStr = "PAUSED"; break;
|
||||
case PlayerStatus::STOPPING: psStr = "STOPPING"; break;
|
||||
case PlayerStatus::LOADING: psStr = "LOADING"; break;
|
||||
default: break;
|
||||
}
|
||||
player["status"] = psStr;
|
||||
|
||||
Reference in New Issue
Block a user