Go Live On Social Media - React Native
This feature allows participant to broadcast meeting on various social media platforms such as Facebook or Youtube. This guide will provide an overview of how participant can start and stop broadcasting meeting.
-
Start LiveStream - By using
startLivestream()function, a participant can start broadcasting meeting on various platforms by provding url and stream keys as an argument. -
Stop LiveStream - By using
stopLivestream()function, a participant can stop broadcasting on all platforms.
note
This page uses the following asynchronous methods. Refer to their API reference for the errors each Promise may reject with, and handle these rejections appropriately based on your use case.
Start And Stop Live Stream
import { useMeeting } from "@videosdk.live/react-native-sdk";
const MeetingView = () => {
const { startLivestream, stopLivestream } = useMeeting();
const onPress = async () => {
// Start Live Stream
try {
await startLivestream([
{
url: "rtmp://a.rtmp.youtube.com/live2",
streamKey: "key",
},
]);
} catch (err) {
console.error("startLivestream failed:", err);
}
// Stop Live Stream
try {
await stopLivestream();
} catch (err) {
console.error("stopLivestream failed:", err);
}
};
return <>...</>;
};
Event
- onLivestreamStateChanged - Whenever broadcasting of meeting started / stopped,
onLivestreamStateChanged()event will trigger.
import { Constants, useMeeting } from "@videosdk.live/react-native-sdk";
function onLivestreamStateChanged(data) {
const { status } = data;
if (status === Constants.livestreamEvents.LIVESTREAM_STARTING) {
console.log("Meeting livestream is starting");
} else if (status === Constants.livestreamEvents.LIVESTREAM_STARTED) {
console.log("Meeting livestream is started");
} else if (status === Constants.livestreamEvents.LIVESTREAM_STOPPING) {
console.log("Meeting livestream is stopping");
} else if (status === Constants.livestreamEvents.LIVESTREAM_STOPPED) {
console.log("Meeting livestream is stopped");
} else {
//
}
}
const {
meetingId
...
} = useMeeting({
onLivestreamStateChanged,
});
Got a Question? Ask us on discord

