# Local player control Furumi exposes a versioned, authenticated WebSocket API to programs on the same computer. It controls the running TUI; it does not start another audio engine or grant membership to a device group. It is independent of the DHT and remains available when federation is disabled. ## Command line ```sh furumi ctl status furumi ctl devices furumi ctl watch furumi ctl play-pause furumi ctl previous furumi ctl next furumi ctl seek -10 furumi ctl volume-up furumi ctl volume-down furumi ctl shuffle furumi ctl repeat furumi ctl radio furumi ctl transfer DEVICE_ID furumi ctl artwork --federation --output cover.png ``` Status, devices and command results are JSON. Watch emits one JSON snapshot per line. Volume changes in five percentage-point steps. Seek is relative, in seconds, bounded to one day per command. A missing or stopped player is an error, not an instruction to start a second player. The existing `--status` / `--status-json` exports remain unchanged. ## Connection and authority The shared `furumi-control-protocol` crate defines the contract and `discovery_path()`. The running player writes `control-endpoint.json` in `directories::ProjectDirs::from("", "", "furumi").data_local_dir()`: ```json {"api_version":1,"port":12345,"token":"RANDOM_PER_PROCESS_TOKEN"} ``` The endpoint binds only to `127.0.0.1`, on an ephemeral port. Connect to `ws://127.0.0.1:PORT` and send authentication as the first message: ```json {"type":"authenticate","api_version":1,"token":"RANDOM_PER_PROCESS_TOKEN"} ``` No metadata or commands are available before authentication. Browser Origin headers are rejected. On Unix the discovery file has mode 0600; on Windows it inherits the user's application-data directory permissions. Tokens must never be included in logs or checked into a profile. A reconnect reads the discovery file again; an old file after an abnormal exit grants no control over a later process. Normal teardown removes the matching endpoint. ## Messages The server sends `{"type":"snapshot","snapshot":{...}}` immediately after authentication. It publishes playback updates at four Hz and sends a snapshot immediately when a remote command changes state. Snapshots include stopped/idle players, the local role, active output, online and offline trusted devices, transfer eligibility, and optional current-track metadata. Revoked devices are omitted. Item keys preserve episode identity; numeric track IDs must not be used as episode identity. Commands carry an opaque unique request ID: ```json {"type":"command","id":"UNIQUE_REQUEST_ID","command":{"type":"seek","seconds":-10}} {"type":"command","id":"ANOTHER_ID","command":{"type":"transfer","device_id":"TRUSTED_DEVICE_ID"}} ``` The result is `{"type":"result","id":"...","accepted":true,"error":null}`. Accepted means dispatched by this player, **not** proof that a remote audio engine started. Subsequent ownership snapshots report coordination state. No audio-ready acknowledgement is invented. Local dispatch results are deduplicated over the most recent 256 command IDs across client connections; reusing an ID with another command is rejected. Clients should generate IDs unique across restarts and avoid automatically replaying non-idempotent commands after uncertain failures. In the personal Control role the controller keeps displaying the last confirmed playback while an operation is in flight. The optional local `remote_command` field contains a monotonically increasing per-session `id`, a `state` (`idle`, `pending`, `confirmed` or `failed`) and an optional English `error`. Confirmation means a fresh heartbeat from the selected owner reports the requested effect. For pause or resume the owner's output flag must agree with its transport state. Concurrent transport requests are rejected while waiting. A write failure, ownership change or 15-second timeout releases the controls. Clients can still navigate or switch devices. Older local API servers omit this field. Transfers recheck trust, presence, Jam restrictions and podcast protocol support. API transfers back to this computer preserve pause. Existing TUI "play here" behavior is unchanged. Jam volume keeps its existing local semantics. Commands use the same playback transitions/effects as media keys. ## Likes `track.liked` is the current music track's state in the user's library. Furumi omits the field while likes are loading and for items such as podcast episodes. Older servers also omit it. Clients enable the heart when they receive a boolean and send the exact `track.key` from that snapshot. ```json {"type":"command","id":"deck-42","command":{"type":"set_liked","track_key":"lib:17","liked":true}} ``` Both `true` and `false` set the requested state. Furumi rejects a key for a track that is no longer current and acknowledges a successful save after reading the state back from the library. Control and Jam clients edit their own personal library. Content-addressed likes use the normal trusted-device replication path. ## Artwork The optional track `artwork_id` is opaque. Request it with `{"type":"command","id":"...","command":{"type":"artwork","artwork_id":"..."}}`. The server returns an `artwork` message with the ID and optional `png_base64`. The default lookup checks the current track and the local release library. Passing `"federation":true` in the command, or `--federation` on the CLI, also permits a lookup through the existing release-cover catalog request when federation is enabled. Furumi tries the active output and known release source first. Global library mode can additionally discover owners of the release through the artist catalog. Private items and podcast metadata are excluded from federated artwork lookup. The CLI returns a JSON artwork response or writes a 384 × 384 PNG to a new file with `--output`. A missing cover has a null `png_base64`. The server coalesces simultaneous lookups and keeps sending snapshots and processing playback commands during a fetch. OpenDeck requests the image when a player key displaying the cover is visible. Its cover button shows a loading indicator, then the image or a neutral framed music note. The service accepts only opaque references for the current track. ## Local spectrum A server that supports audio levels advertises `"spectrum_supported":true` in its normal snapshot. After authentication, a client can send `{"type":"subscribe_spectrum","enabled":true}` and unsubscribe with `"enabled":false`. The subscription belongs to that connection and ends on disconnect. Clients should wait for the advertised capability before subscribing to an older installation. A `spectrum` message contains `epoch`, `sequence` and `bands`. The 31 byte values represent third-octave levels, ordered from 20 Hz to 20 kHz. Values 0–255 cover the analyzer's −60 to 0 dBFS display range. Subscribers receive up to ten samples per second from local playback, including a local Jam host. A pause freezes the history. A new epoch or null bands clears it after a seek, track change, stop or handoff. Slow subscribers receive the latest available sample. Normal playback snapshots retain their own cadence. ## Similarity radio Radio uses the current music track as its seed and creates a temporary play queue, without saving or editing a library playlist. Similarity must already be enabled and the seed must have a local indexed embedding (a remote seed is resolved by content ID against this computer's library). Podcast seeds are rejected. Network queries respect the existing federation consent. The `radio` snapshot field has an operation `id`, a `state` (`idle`, `searching`, `starting`, `playing`, `failed`) and an optional English error. Local and federated candidates are collected asynchronously before the queue is replaced. A bounded peer search is awaited; if peers fail but local matches exist, radio can still play offline. Candidate ranking, deduplication and artist diversity reuse the TUI similarity policy. Search failures, empty results, changed queues/outputs and stale operation results leave the existing queue untouched. `starting` persists through audio preparation; `playing` is emitted after a local audio Started event, or an active output's matching playback report with advancing position. The plugin animates the Radio key until that operation succeeds, then returns to the main screen. Errors keep the Functions screen available. ## OpenDeck The native Rust [OpenDeck integration](../integrations/opendeck/README.md) targets Stream Deck Neo and OpenDeck 2.14.2 on Windows, macOS and Linux. It renders eight 96 × 96 key images and a 248 × 58 Infobar, and maintains its own player/device screens within one OpenDeck profile. The API limits connections, command queues, request IDs, message sizes, authentication time and slow writes. A slow plugin cannot hold up terminal rendering: snapshots use a latest-value watch channel. It has no authority to pair, revoke or otherwise change trusted-device membership.