useAudioPlayer

Audio
stable

Headless audio player composable. A typed wrapper around useMediaPlayer that exposes a typed `audioRef` (HTMLAudioElement) instead of the generic HTMLMediaElement, and reserves a stable extension point for future audio-specific features such as waveform analysis, Web Audio AnalyserNode wiring, and AudioWorklet pipes.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

useAudioPlayer is a thin typed adapter — all runtime logic lives in useMediaPlayer. Use this composable when building a custom audio UI that needs a properly typed `HTMLAudioElement` ref; use useMediaPlayer directly when the element type is dynamic.

Consumed interfaces

IUseOrigamAudioPlayerOptions
IAudioPlayerState
IAudioPlayerMethods

API

Parameters

Input parameters accepted by this composable.

options
IUseOrigamAudioPlayerOptions
{}
Optional configuration. Accepts `audioRef` (bring your own ref), `autoplay`, `muted`, `loop`, and `preload`. All fields are optional.

API

Return values

Properties and methods exposed by the composable return object.

audioRef
Template ref to bind to the native `<audio>` element. If `options.audioRef` was provided it is returned as-is; otherwise a new ref is created.
state
Reactive playback state: playing, paused, currentTime, duration, buffered, volume, muted, ready, loading, error, playbackRate, remoteAvailable, remoteState.
methods
Imperative controls: play, pause, toggle, seek, setVolume, toggleMute, load, skipBackward, skipForward, setPlaybackRate, requestRemotePlayback, stopRemotePlayback.

Usage

Examples

Ready-to-paste usage snippets.

Minimal headless audio player

vue

Using OrigamAudio (recommended)

vue