Skip to main content
useMediaTrack(params) : Object There are also convenience hooks for each track type.

Parameters

session_id
string
required
A unique identifier for the participant
type
string
default:"'video'"
'audio' | 'screenAudio' | 'screenVideo' | 'video', specifies the kind of track

Return value

An object with the following properties:
MediaTrackState
Object
Includes detailed information about the given track. See participant tracks properties
isOff
boolean
Indicates 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.

Example

import { useMediaTrack } from '@daily-co/daily-react';

export const UseMediaTrackDemo = (props) => {
  const sessionID = props.session_id;
  const mediaTrack = useMediaTrack(sessionID, "audio");

  return (
      <div>Audio {mediaTrack.isOff ? "off" : "on"}</div>
  )
};

See also