Skip to main content
Version: 2.x.x

Stream Events - React Native

onStreamStateChanged​

  • This event is triggered when the state of a stream changes.
  • The event callback will include the current state of the stream, which can be one of the following values: ACTIVE, FREEZE_DETECTED, FREEZE_RESOLVED, STUCK, ENDED.
  • It can be subscribed to using the useRTCStream hook.
note

This event is emitted exclusively for remote participants, specifically for their video and screen share video streams.

Parameters​

  • state: Specifies the current state of the stream.

    • Type: String
    • Possible values:
      • "ACTIVE": Stream is working normally.
      • "STUCK": Stream is not progressing as expected.
      • "FREEZE_DETECTED": Video freeze has been detected.
      • "FREEZE_RESOLVED": Video freeze has been resolved.
      • "ENDED": Stream has ended.
  • timestamp: The time (in milliseconds since epoch) when the state change occurred.

    • Type: Number

Example​

Here is an example demonstrating the usage of the event mentioned on this page.

import { useRTCStream, useParticipant } from "@videosdk.live/react-native-sdk";

function onStreamStateChanged(data) {
const { state, timestamp } = data;
}

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

API Reference​

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord