Skip to main content
Version: 2.x.x

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.

  1. Start Recording - By using startRecording() function, a participant can start room recording.

  2. Stop Recording - By using stopRecording() function, a participant can stop room recording.

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 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​

  1. onRecordingStarted - Whenever any participant starts room recording, then onRecordingStarted event will trigger.

  2. onRecordingStopped - Whenever any participant stops room recording, then onRecordingStopped event will trigger.

  3. onRecordingStateChanged - Whenever room recording state changes, then onRecordingStateChanged event 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