Record Room - React Native
Record room allows participants to record video & audio during the room. The recording files are available in developer dashboard. Any participant can start / stop recording any time during the room.
This guide shows how to start and stop recording a room.
-
Start Recording - By using
startRecording()function, a participant can start room recording. -
Stop Recording - By using
stopRecording()function, a participant can stop room recording.
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 Recording
import { useRoom } from "@videosdk.live/react-native-sdk";
const RoomView = () => {
const { startRecording, stopRecording } = useRoom();
const onPress = async () => {
// Start Recording
try {
await startRecording(webhookUrl, awsDirPath);
} catch (err) {
console.error("startRecording failed:", err);
}
// Stop Recording
try {
await stopRecording();
} catch (err) {
console.error("stopRecording failed:", err);
}
};
return <>...</>;
};
Events
-
onRecordingStarted - Whenever any participant starts room recording, then
onRecordingStartedevent will trigger. -
onRecordingStopped - Whenever any participant stops room recording, then
onRecordingStoppedevent will trigger. -
onRecordingStateChanged - Whenever room recording state changes, then
onRecordingStateChangedevent will trigger.
import { Constants, useRoom } from "@videosdk.live/react-native-sdk";
function onRecordingStateChanged(data) {
const { state } = data;
if (state === Constants.recordingEvents.RECORDING_STARTING) {
console.log("Room recording is starting");
} else if (state === Constants.recordingEvents.RECORDING_STARTED) {
console.log("Room recording is started");
} else if (state === Constants.recordingEvents.RECORDING_STOPPING) {
console.log("Room recording is stopping");
} else if (state === Constants.recordingEvents.RECORDING_STOPPED) {
console.log("Room recording is stopped");
} else {
//
}
}
/** useRoom hooks events */
const {
/** Methods */
} = useRoom({
onRecordingStarted: () => {
console.log("Recording Started");
},
onRecordingStopped: () => {
console.log("Recording Stopped");
},
onRecordingStateChanged,
});
Got a Question? Ask us on discord

