Skip to content

feat: scaffold API, commands and tests#2

Merged
jjhafer merged 1 commit intosilvermine:masterfrom
velocitysystems:api
Mar 19, 2026
Merged

feat: scaffold API, commands and tests#2
jjhafer merged 1 commit intosilvermine:masterfrom
velocitysystems:api

Conversation

@velocitysystems
Copy link
Contributor

Summary

Scaffolds the API contract for headless native audio playback: Tauri commands, TypeScript bindings, state machine, event system, and mock Rust implementation.

API design inspired by Vidstack's audio provider model, adapted for native platform integration with OS transport controls (lock screen, notification shade, headphone buttons)

Architecture

State machine with 7 statuses (Idle, Loading, Ready, Playing, Paused, Ended, Error) gates transport actions (load, play, pause, stop, seek) at both the Rust and TypeScript layers. The TypeScript type system enforces this via discriminated unions — only valid actions are available on the Player object for a given status.

Two event channels separate high-frequency time progression from infrequent state transitions:

  • state-changed — status transitions, settings, errors (full PlayerState)
  • time-update — currentTime/duration progression (lightweight TimeUpdate, ~250ms during playback)

Always-available controls (setVolume, setMuted, setPlaybackRate, setLoop, listen, onTimeUpdate) are not gated by status — they work regardless of playback state.

Design decisions

  • Single player — OS transport controls map to one active session; consuming apps build queue management on top
  • Transport actions vs controls separation — Transport actions return AudioActionResponse with expected-status metadata; settings return the updated PlayerWithAnyStatus directly

Test plan

  • npm run standards passes (eslint, tsc, markdownlint, clippy, rustfmt, commitlint, check-node-version)
  • npm test passes (23 TypeScript + 24 Rust tests)
  • All state transitions tested (happy path and error cases)
  • NaN/Infinity rejection tested for volume, playback rate, seek
  • Clamping boundary values tested
  • Action gating verified for all 7 statuses
  • Player controls verified as always-available (Idle and Error)

Copy link

@pmorris-dev pmorris-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block on these suggestions. Leaving it up to you, @velocitysystems.

@jjhafer jjhafer merged commit 08592e0 into silvermine:master Mar 19, 2026
1 check passed
@velocitysystems velocitysystems deleted the api branch March 19, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants