useStream Hook Event Callbacks - React
onStreamStateChanged()
onStreamStateChanged()is a callback which is triggered when the state of a video or screen-share video stream of the remote participant changes. It helps track whether the stream is active, stuck, frozen, resolved, or ended.
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.
- Type:
-
timestamp: The time (in milliseconds since epoch) when the state change occurred.- Type:
Number
- Type:
Example
function onStreamStateChanged({ state, timestamp }) {
console.log("onStreamStateChanged ", state,timestamp);
}
const { webcamStream } = useParticipant(participantId)
const {
...
} = useStream(webcamStream?.id,{
onStreamStateChanged
});
Got a Question? Ask us on discord

