AudioTrack
function AudioTrack(__namedParameters): Element;Defined in: packages/react/src/components/track/AudioTrack.tsx:44
The AudioTrack component is responsible for rendering participant audio tracks. This component must have access to the participant's context, or alternatively pass it a Participant as a property.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | AudioTrackProps |
Returns
Element
Example
// Basic — render a participant audio track.
<ParticipantTile>
<AudioTrack trackRef={trackRef} />
</ParticipantTile>
// Advanced — render subscribed microphone audio for the room.
function RoomAudioTracks() {
const tracks = useTracks([Track.Source.Microphone], { onlySubscribed: true });
return (
<VoiceRoom agent={agent}>
{tracks.map((trackRef, index) => (
<AudioTrack key={index} trackRef={trackRef} volume={0.8} />
))}
<RoomAudioRenderer />
</VoiceRoom>
);
}