SoundPlayer

interface SoundPlayer

Plays short SFX by SoundKey and fires haptics by HapticPattern.

Contract:

  • All methods are fire-and-forget and must never throw (a missing audio device, a denied haptic permission, or a headless CI box must degrade to a silent no-op).

  • playSound / haptic are expected to be called by the caller only when its master sound toggle is ON; implementations need not re-check a preference.

  • release frees native resources (SoundPool, audio lines). Idempotent.

The jvm actual genuinely emits audio (a tiny javax.sound tone synth) so the desktop build is verifiably audible; the wasm actual uses Web Audio where available and otherwise degrades to a no-op.

Functions

Link copied to clipboard
abstract fun haptic(pattern: HapticPattern)

Fire a device haptic. No-op on platforms with no vibrator (desktop/web).

Link copied to clipboard
abstract fun playSound(key: SoundKey)

Play the SFX mapped to key. No-op if audio is unavailable.

Link copied to clipboard
abstract fun release()

Release native resources. Safe to call more than once.