Audio Player
React Native audio player built on expo-av with MobX Keystone state management. Handles recording, playback, seeking, and waveform rendering for conversation sessions.
Player Store (MobX Keystone Model)
A single AudioPlayerStore model owns all playback and recording state. Views derive UI-ready values (formatted time, progress percentage, waveform slices). Actions mutate state in response to native callbacks. The store is registered as a root model so Keystone snapshots can persist playback position across app suspends.
Native Audio Bridge (Adapter)
A thin adapter wraps expo-av Audio.Sound and Audio.Recording behind a platform-agnostic interface. The bridge translates native callbacks (onPlaybackStatusUpdate, onRecordingStatusUpdate) into MobX Keystone actions on the store. No domain logic lives in the bridge — it is purely I/O.
Architecture
Components
audio-player-store
MobX KeystoneRoot state model: currentRecordingId, status (idle | recording | playing | paused), positionMs, durationMs, metering levels. Exposes actions for play, pause, seek, startRecording, stopRecording. Derives formatted timestamps and progress ratio as views.
-
audio-bridge— Delegates to the native bridge for all expo-av interactions.
-
play-audio -
start-recording -
pause-recording -
resume-recording -
stop-recording
-
recording-started -
recording-stopped
audio-bridge
expo-avWraps Audio.Sound and Audio.Recording. Creates, loads, and releases native resources. Forwards status updates to the store via callback injection. Handles iOS audio session category configuration and Android focus management.
-
file-storage— Reads and writes audio files from local storage.
file-storage
expo-file-systemManages the on-device audio file directory. Provides paths for new recordings and resolves paths for playback. Handles cleanup of orphaned files.
player-ui
React NativeRenders playback controls (play/pause, seek bar, timestamp), recording indicator with live metering, and waveform visualization. Observes the audio-player-store via mobx-react-lite . Shows recording indicator and live duration counter. Transitions UI to playback-ready state.
-
audio-player-store— Reads state and dispatches actions.
-
recording-started — Shows recording indicator and live duration counter. -
recording-stopped — Transitions UI to playback-ready state.
Rules
| Rule | Force | Realm | Reference | Description |
|---|---|---|---|---|
no-bridge-logic | | | — | The audio bridge must contain zero domain logic. All state transitions happen in the store; the bridge only translates native callbacks. |
release-resources | | | — | Audio.Sound and Audio.Recording instances must be unloaded when the player unmounts or switches recordings, to prevent memory leaks on both platforms. |