React Api Reference
    Preparing search index...

    Class useStream

    useStream provides reactive access to a participant’s audio, video, and screen-share streams along with stream controls and events.

    Index

    Constructors

    Properties

    codec: string

    This represents the codec used to encode and decode the stream.

    kind: "audio" | "video" | "share" | "shareAudio"

    This represents the kind of the stream.

    paused: boolean

    This represents whether the stream is currently paused.

    stream: Stream

    This represents the Stream instance.

    track: MediaStreamTrack

    This represents the underlying media track associated with the stream.

    Methods

      • This method can be used to pause the stream for a remote participant.

      Returns void

      • This method can be used to resume the stream for a remote participant.

      Returns void

    Events

      • Triggered when the state of a video or screen-share stream changes.

      • This event helps track whether the stream is active, stuck, frozen,recovered, or ended.

      Note

      This event is emitted only for remote participants and applies specifically to video and screen-share streams.

      Parameters

      • option: { state: string; timestamp: number }
        • state: string

          The current state of the stream:

          • "active" — The stream is functioning normally.
          • "stuck" — The stream is no longer progressing as expected.
          • "freeze-detected" — A freeze in the video stream has been detected.
          • "freeze-resolved" — The previously detected freeze has been resolved.
          • "ended" — The stream has ended.
        • timestamp: number

          Timestamp (in milliseconds since epoch) indicating when the state change occurred.

      Returns void

      function onStreamStateChanged({ state, timestamp }) {
      console.log("onStreamStateChanged ", state,timestamp);
      }

      const { webcamStream } = useParticipant(participantId)
      const {
      ...
      } = useStream(webcamStream?.id,{
      onStreamStateChanged
      });