@molecule/app-audio-expo

Provider bond · audio · App (browser) · v1.0.1 · Apache-2.0

Expo audio playback provider for molecule.dev.

npm install @molecule/app-audio-expo

npm · Source on GitHub · Implements @molecule/app-audio

How it works

@molecule/app-audio-expo is a provider bond on the app (browser) side: it implements the audio core interface (@molecule/app-audio) with a concrete vendor or library behind it.

Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.

import { setProvider } from '@molecule/app-audio'
import { provider } from '@molecule/app-audio-expo'

setProvider(provider)

Works with: @molecule/app-audio, @molecule/app-logger

Reference

Expo audio playback provider for molecule.dev.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { setProvider } from '@molecule/app-audio'
import { provider } from '@molecule/app-audio-expo'

setProvider(provider)

Type

provider

Installation

npm install @molecule/app-audio-expo @molecule/app-audio @molecule/app-logger expo-audio react-native

API

Constants

provider

Audio playback through the Expo SDK's native player.

const provider: AudioProvider

Core Interface

Implements @molecule/app-audio interface.

Bond Wiring

Setup function to register this provider with the core interface:

import { setProvider } from '@molecule/app-audio'
import { provider } from '@molecule/app-audio-expo'

export function setupAudioExpo(): void {
  setProvider(provider)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-audio ^1.0.0
  • @molecule/app-logger ^1.0.0
  • expo-audio 0.4.9
  • react-native 0.79.6

Runtime Dependencies

  • @molecule/app-audio
  • @molecule/app-logger
  • expo-audio
  • react-native

The expo-audio peer is pinned to the version bundled with Expo SDK 53. A bare React Native app needs Expo modules installed before it can use this provider. Destroy each player when it is no longer needed to release its native resources. For multiple source URLs, Expo tries them in order. A source that fails or takes over ten seconds to load gives the next URL a chance.

E2E Tests

Playback verification — drive the real rendered UI (live preview, no mocks), adapt each item to this app's actual audio screens/controls, and check every box off one by one. This core is PLAYBACK ONLY (no recording); a box you can't check is an integration bug to fix — not a skip:

  • Loading a track and pressing the play control actually plays: the current-time readout advances, the progress bar moves, and the UI shows the playing state (isPlaying() true, getCurrentTime() keeps climbing). Confirm sound is audible, not just that the state flipped — start it from a click/tap so autoplay policy does not silently block it.
  • The pause control halts playback: current time freezes, the progress bar stops, and the control toggles back to "play"; pressing play resumes from the same position, not the start.
  • Dragging/clicking the scrubber to a target position seeks there: getCurrentTime() jumps to that time and the displayed elapsed time matches.
  • The volume/mute control changes output: raising/lowering the slider is audible and getVolume() reflects it; muting (volume 0) silences the audio without pausing it.
  • Total duration and elapsed time render correctly once metadata loads (getDuration() > 0, read via onProgress), not "0:00 / 0:00" stuck on screen.
  • Reaching the end fires the ended state: the onEnd callback runs and the UI resets to the start (or advances to the next track), not a silent hang.
  • The audio source loads from the app's own origin (a bundled/served asset), not a broken external URL — no 404/CORS error in the console and sound actually reaches the output.