useMediaTrack

useMediaTrack(params) : Object

Given a participant session_id and type of track, returns the corresponding track and its state.

There are also convenience hooks for each track type.

Params

ParameterRequiredTypeDescription
session_idstringA unique identifier for the participant
typestring'audio' | 'screenAudio' | 'screenVideo' | 'video', specifies the kind of track, defaults to 'video'

Return type

An object with the following properties:

NameTypeDescription
MediaTrackStateObjectIncludes detailed information about the given track. See participant tracks properties
isOffbooleanIndicates whether a track is turned off or on, true when track state is 'blocked' | 'off'

Convenience hooks for specific track types

useAudioTrack

useAudioTrack(session_id: string) : MediaTrackState

Given a participant's session_id, returns the MediaTrackState of their 'audio' track.

useScreenAudioTrack

useScreenAudioTrack(session_id: string) : MediaTrackState

Given a participant's session_id, returns the MediaTrackState of their 'screenAudio' track.

useScreenVideoTrack

useScreenVideoTrack(session_id: string) : MediaTrackState

Given a participant's session_id, returns the MediaTrackState of their 'screenVideo' track.

useVideoTrack

useVideoTrack(session_id: string) : MediaTrackState

Given a participant's session_id, returns the MediaTrackState of their 'video' track.

Sample code