Skip to main content
Version: 2.x.x

RTMP Events - React Native

VideoSDK provides the onLivestreamStateChanged() event, which informs you about the current state of the livestream for the room.

onLivestreamStateChanged()​

  • This event is triggered when the livestream state of the room changes.
  • It can be subscribed to using the useRoom hook.

Example​

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

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

function onLivestreamStateChanged(data) {
const { state } = data;

if (state === Constants.livestreamEvents.LIVESTREAM_STARTING) {
console.log("Room livestream is starting");
} else if (state === Constants.livestreamEvents.LIVESTREAM_STARTED) {
console.log("Room livestream is started");
} else if (state === Constants.livestreamEvents.LIVESTREAM_STOPPING) {
console.log("Room livestream is stopping");
} else if (state === Constants.livestreamEvents.LIVESTREAM_STOPPED) {
console.log("Room livestream is stopped");
} else {
//
}
}

const { roomId } = useRoom({
onLivestreamStateChanged,
});

API Reference​

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

Got a Question? Ask us on discord