Skip to content
Audio Player
AutoXXS (320px)XS (375px)SM (640px)MD (768px)LG (1024px)XL (1280px)XXL (1536px)
SketchMaterialiOSTamagui
DataInjectionKeyPatternsServiceTransactionProcessResearchProductQualityPerformanceSpecDomainFunctionTechnologyArchitectureConfigMiddlewareDataDatabaseDrizzleMigrationModelop-sqliteSchemaSQLState ManagementDraftKeystoneMergePatchPatchesPersistenceReactiveRedoStoreUndoTestingDeviceFactoryIsolationTypeScriptZodTopicsCommunicationBidsNVCDesignDesign ImplicationsEducationPedagogyFoundationsPsychologyAttachmentFloodingRelatingAuthentic RelatingUIEditorReact Native

Audio Player

module

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

architecture Audio Player architecture
Gallery

Components

store

audio-player-store

MobX Keystone

Root 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.

Collaborates with
  • audio-bridge — Delegates to the native bridge for all expo-av interactions.
Implements
  • play-audio
  • start-recording
  • pause-recording
  • resume-recording
  • stop-recording
Emits
  • recording-started
  • recording-stopped
adapter

audio-bridge

expo-av

Wraps 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.

Collaborates with
  • file-storage — Reads and writes audio files from local storage.
infrastructure

file-storage

expo-file-system

Manages the on-device audio file directory. Provides paths for new recordings and resolves paths for playback. Handles cleanup of orphaned files.

ui

player-ui

React Native

Renders 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.

Collaborates with
  • audio-player-store — Reads state and dispatches actions.
Listens to
  • 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 must global The audio bridge must contain zero domain logic. All state transitions happen in the store; the bridge only translates native callbacks.
release-resources must global Audio.Sound and Audio.Recording instances must be unloaded when the player unmounts or switches recordings, to prevent memory leaks on both platforms.