RemoteAudioStream interface
extends AudioStream REMOTE
A remote participant's microphone stream. Adds server-driven state, per-participant volume control, and audio level observation. Access via p.audio after subscribe().
Blueprint
Members added on top of AudioStream. Audio doesn't surface a degraded state and has no decoder-side observations.
<audio> element and plays remote audio automatically โ no manual attach needed for the common case. Use attach only for custom routing.Properties (added)
Plus inherited from AudioStream: id, codec, isPlaying, isMuted, isEnded.
streamState
Server-driven routing state. See StreamState. Audio doesn't surface a degraded state โ audio is small enough that the server doesn't bandwidth-suppress it.
audioLevel
Current sound level from this participant's mic, normalized 0..1. Sync getter โ poll at your desired interval (every 100ms is typical for speaking-ring UIs).
setInterval(() => {
for (const p of room.remoteParticipants.values()) {
const level = p.audio?.audioLevel ?? 0;
updateSpeakingRing(p.id, level); // CSS scale on a ring around the tile
}
}, 100);
Methods (added)
Plus inherited from AudioStream: attach, getStats, getMediaStreamTrack.
setVolume
Set playback volume (0..1) for this remote participant's audio. Applies to the SDK-managed internal <audio> element.
levelโ 0 (silent) to 1 (full volume). Values outside this range are clamped.
volumeSlider.addEventListener('input', () => {
p.audio.setVolume(volumeSlider.valueAsNumber);
});
Events
A single state-changed event covers every routing transition. Subscribe-completion events (audio-subscribed, audio-unsubscribed) fire on RemoteParticipant.
| Event | Payload |
|---|---|
state-changed | { state: StreamState } |
Fires when streamState changes. Audio surfaces only 'active', 'paused', and 'ended' โ no 'degraded' (audio isn't bandwidth-suppressed) and no decoder-side states ('frozen' / 'stuck' are RemoteVideoStream-only).
p.audio.on('state-changed', ({ state }) => {
if (state === 'ended') cleanupAudio(p);
});
See also: AudioStream RemoteParticipant LocalAudioStream Room.setOutputDevice