feat(Player): segmented mode "infinite" via duration + pause_duration (F-077, v2.5.0)
"infinite" now optionally plays duration ms, pauses pause_duration ms and repeats until playback.stop, the same as "interval" with total_duration 0, which is what people expect "infinite" to mean. Sending neither keeps the old back-to-back looping; sending only one is rejected, since a duration without a pause flickers paused/playing and a pause without a duration never triggers. total_duration is never read for infinite. api-reference.md now documents the exact timing of every mode: 500 ms tick, loops never cut short, paused/stopping status transitions, pause measured from the loop end, total_duration including pauses, and the ~0.5 s engine gap between loops when the run has no end time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,7 @@ Check `git log -- src/Version.hpp` for the real bump history before tagging a ne
|
||||
| F-074 | Fix: `mode: "infinite"` no longer flips status playing/paused every ~0.5 s | v2.4.0 | Stable |
|
||||
| F-075 | Play/stop command replies no longer wait for telemetry SD writes (deferred to TelemetryTask) | v2.4.1 | Stable |
|
||||
| F-076 | Fix: a `pause_duration` shorter than one melody loop no longer gets skipped | v2.4.2 | Stable |
|
||||
| F-077 | `mode: "infinite"` accepts optional `duration` + `pause_duration` for play/pause cycles forever | v2.5.0 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -345,7 +346,10 @@ V2 play commands replace the ambiguous `continuous_loop` / `segment_duration` /
|
||||
| `"single"` | Play exactly one melody loop, then stop | none |
|
||||
| `"timed"` | Loop continuously for `duration` ms, stop at end of a full loop | `duration` |
|
||||
| `"interval"` | Loop for `duration` ms, pause for `pause_duration` ms, repeat until `total_duration` ms elapsed | `duration`, `pause_duration`, `total_duration` |
|
||||
| `"infinite"` | Loop forever until a `stop` command | none |
|
||||
| `"infinite"` | Loop forever until a `stop` command; optionally in `duration`/`pause_duration` segments (F-077) | none, or `duration` + `pause_duration` |
|
||||
|
||||
Exact per-mode timing (500 ms tick, loops never cut short, pause/status transitions, the ~0.5 s gap between loops):
|
||||
see `docs/reference/api-reference.md` → `playback.play` → Modes.
|
||||
|
||||
V1 timing fields (`segment_duration`, `continuous_loop`, `total_duration`) are still parsed when `mode` is absent, so the fix from F-024 continues to apply to V1 clients.
|
||||
|
||||
@@ -1585,3 +1589,20 @@ playing when the pause was flagged has ended. The silence now always lasts `paus
|
||||
500 ms timer tick), measured from the end of that loop. Pauses longer than one loop already worked this way.
|
||||
|
||||
Subsystem: `src/Player/Player.cpp`
|
||||
|
||||
### F-077 — Segmented `mode: "infinite"`
|
||||
|
||||
**Why.** "Play/pause forever" was only possible as `interval` with `total_duration: 0`, which nobody guesses.
|
||||
`infinite` reads as "never stops on its own", and the pauses should be an option of it.
|
||||
|
||||
**Change.** `infinite` now reads `duration` and `pause_duration`:
|
||||
|
||||
| Sent | Behaviour |
|
||||
|---|---|
|
||||
| neither (or both `0`) | Unchanged: back-to-back loops (with the ~0.5 s engine gap) until `playback.stop`. |
|
||||
| both > 0 | Play `duration` ms, pause `pause_duration` ms, repeat until `playback.stop`. Same internal state as `interval` with `total_duration: 0`. |
|
||||
| only one > 0 | Rejected: `Invalid infinite segments: duration and pause_duration must both be > 0, or both omitted`. A duration with no pause would pause and resume on the same tick, and a pause with no duration never triggers. |
|
||||
|
||||
`total_duration` is never read for `infinite`. `interval` with `total_duration: 0` still works as before.
|
||||
|
||||
Subsystem: `src/Player/Player.cpp` (`validatePlayParams`, `setMelodyAttributes`)
|
||||
|
||||
Reference in New Issue
Block a user