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/reactuseAudioPlayer
Function●Since v1.0

useAudioPlayer

Progressive audio playback for AudioMedia handles with a uniform surface across PCM (streamed) and container (HTMLAudioElement) strategies.

Behaviour

  • Strategy selection is derived from media.mimeType and may be overridden via options.strategy. PCM / L16 / WAV all flow through the progressive Web Audio path; every other mime uses a hidden HTMLAudioElement.

  • PCM strategy. Chunks are decoded in real time and scheduled on a single AudioContext; playback begins within one chunk of the first byte. seek / duration are undefined because random access on a live scheduled buffer is not supported.

  • Element strategy. status stays in "buffering" until message-finish materialises a blob URL; the element then owns playback. seek / duration are available.

  • Both strategies expose level, getFrequencyData(), and getTimeDomainData() by tapping an AnalyserNode in the audio graph.

  • React StrictMode's simulated unmount/remount is safe: the shared reader and replay buffer mean a second attach sees the same bytes that the first one did.

Copy
useAudioPlayer(media: AudioMedia | undefined, options: UseAudioPlayerOptions): AudioPlayerHandle

Parameters

NameTypeDescription
media*AudioMedia | undefined

Audio handle from useAudio etc.

optionsUseAudioPlayerOptions

Strategy overrides and PCM format hints.

View source on GitHub