LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/reactAudioPlayerHandle
Interface●Since v1.0

AudioPlayerHandle

Player controls + live state returned by useAudioPlayer.

Shape is shared with useVideoPlayer where possible — learn one surface, use it for both.

Copy
interface AudioPlayerHandle

Properties

property
currentTime: number

Seconds of audio consumed since the current play() call. Resets on reset() and on media changes.

property
duration: number

Total duration in seconds, when knowable. The element strategy exposes this once loadedmetadata fires; the pcm strategy leaves it undefined (PCM duration isn't known until message-finish).

property
error: Error | undefined

Last error raised by the stream reader, decoder, or element.

property
level: number

RMS level of the last analysed frame, normalised to [0, 1]. Drop-in for a VU meter. 0 when no analyser frame has been read yet, when paused, or before play().

property
status: PlayerStatus

Current lifecycle state. See PlayerStatus.

property
strategy: "pcm" | "element"

Which implementation is active. "pcm" scheduling through AudioContext starts within one chunk of the first byte; "element" waits for message-finish before a hidden HTMLAudioElement takes over.

Methods

method
getFrequencyData→ Uint8Array<ArrayBufferLike> | undefined

Current 256-bin frequency-domain snapshot from the internal AnalyserNode. Returns undefined before the graph is connected or on environments without Web Audio. Safe to poll inside requestAnimationFrame.

method
getTimeDomainData→ Uint8Array<ArrayBufferLike> | undefined

Current 256-sample waveform snapshot (byte time-domain) from the internal AnalyserNode. Returns undefined before the graph is connected or on environments without Web Audio.

method
pause

Pause without discarding buffered samples / element position.

method
play

Start (or resume) playback. No-op while status === "error".

method
playToEnd→ Promise<void>

Resolve on the next terminal transition (finished | paused | idle). Reject on transitions to "error". Calling stop() or reset() resolves the pending promise immediately. Calling playToEnd also triggers play() if currently paused/idle.

method
reset

Reset back to "idle" and drop any transient error. The next play() starts fresh from the current position.

method
seek

Seek to an absolute timestamp in seconds. Only defined on the element strategy; undefined on pcm (random-access seeking of a live scheduled buffer is not supported).

method
stop

Hard stop: tears down the AudioContext (PCM) or detaches the element (element) and drops any scheduled work.

method
toggle

Sugar for status === "playing" ? pause() : play().

View source on GitHub