Setting the file. One moment.
Subchapter 149.11
examples/recording.mdMarkdown10 KBView on GitHub
Complete guide to controlling cloud recording in the Zoom Video SDK for Web.
// Get recording client after joining session
const recordingClient = client.getRecordingClient();// Check if cloud recording is available
const canRecord = recordingClient.canStartRecording();
if (!canRecord) {
console.log('Cloud recording not enabled for this session');
}try {
await recordingClient.startCloudRecording();
console.log('Recording started');
} catch (error) {
console.error('Failed to start recording:', error);
}try {
await recordingClient.stopCloudRecording();
console.log('Recording stopped');
} catch (error) {
console.error('Failed to stop recording:', error);
}// Pause
await recordingClient.pauseCloudRecording();
// Resume
await recordingClient.resumeCloudRecording();import { RecordingStatus } from '@zoom/videosdk';
const status = recordingClient.getCloudRecordingStatus();
switch (status) {
case RecordingStatus.Recording:
console.log('Currently recording');
break;
case RecordingStatus.Paused:
console.log('Recording paused');
break;
case RecordingStatus.Stopped:
console.log('Not recording');
break;
}client.on('recording-change', (payload) => {
const { state } = payload;
switch (state) {
case 'Recording':
showRecordingIndicator();
break;
case 'Paused':
showPausedIndicator();
break;
case 'Stopped':
hideRecordingIndicator();
break;
}
});When individual recording is enabled, participants must consent:
client.on('individual-recording-change', (payload) => {
const { state, userId } = payload;
switch (state) {
case 'Ask':
// Host is asking you to accept individual recording
showRecordingConsentDialog();
break;
case 'Accept':
// User accepted recording
console.log('User', userId, 'accepted recording');
break;
case 'Decline':
// User declined recording
console.log('User', userId, 'declined recording');
break;
}
});// Accept individual recording
await recordingClient.acceptIndividualRecording();
// Decline individual recording
await recordingClient.declineIndividualRecording();import { RecordingStatus } from '@zoom/videosdk';
class RecordingManager {
constructor(client) {
this.client = client;
this.recordingClient = null;
this.currentStatus = RecordingStatus.Stopped;
this.onStatusChange = null;
this.onConsentRequired = null;
}
init() {
this.recordingClient = this.client.getRecordingClient();
this.currentStatus = this.recordingClient.getCloudRecordingStatus();
this.setupEventListeners();
}
setupEventListeners() {
// Recording state changes
this.client.on('recording-change', (payload) => {
this.currentStatus = payload.state;
if (this.onStatusChange) {
this.onStatusChange(payload.state);
}
});
// Individual recording consent
this.client.on('individual-recording-change', (payload) => {
if (payload.state === 'Ask' && this.onConsentRequired) {
this.onConsentRequired();
}
});
}
canStartRecording() {
return this.recordingClient.canStartRecording();
}
isRecording() {
return this.currentStatus === 'Recording' ||
this.currentStatus === RecordingStatus.Recording;
}
isPaused() {
return this.currentStatus === 'Paused' ||
this.currentStatus === RecordingStatus.Paused;
}
async start() {
if (!this.canStartRecording()) {
throw new Error('Cloud recording not available');
}
if (this.isRecording()) {
throw new Error('Already recording');
}
await this.recordingClient.startCloudRecording();
}
async stop() {
if (!this.isRecording() && !this.isPaused()) {
throw new Error('Not currently recording');
}
await this.recordingClient.stopCloudRecording();
}
async pause() {
if (!this.isRecording()) {
throw new Error('Not currently recording');
}
await this.recordingClient.pauseCloudRecording();
}
async resume() {
if (!this.isPaused()) {
throw new Error('Recording not paused');
}
await this.recordingClient.resumeCloudRecording();
}
async acceptConsent() {
await this.recordingClient.acceptIndividualRecording();
}
async declineConsent() {
await this.recordingClient.declineIndividualRecording();
}
getStatus() {
return this.recordingClient.getCloudRecordingStatus();
}
}
// Usage
const recordingManager = new RecordingManager(client);
recordingManager.init();
recordingManager.onStatusChange = (status) => {
updateRecordingUI(status);
};
recordingManager.onConsentRequired = () => {
showConsentDialog({
onAccept: () => recordingManager.acceptConsent(),
onDecline: () => recordingManager.declineConsent(),
});
};
// UI handlers
document.getElementById('start-recording').onclick = async () => {
try {
await recordingManager.start();
} catch (error) {
alert(error.message);
}
};
document.getElementById('stop-recording').onclick = async () => {
try {
await recordingManager.stop();
} catch (error) {
alert(error.message);
}
};import React, { useState, useEffect } from 'react';
import { VideoClient, RecordingStatus } from '@zoom/videosdk';
interface RecordingControlsProps {
client: typeof VideoClient;
isHost: boolean;
}
export const RecordingControls: React.FC<RecordingControlsProps> = ({
client,
isHost
canStartRecording() first - Recording must be enabled on the accountindividual-recording-changetry {
await recordingClient.startCloudRecording();
} catch (error) {
if (error.type === 'INVALID_OPERATION') {
// Recording not available or already recording
} else if (error.type === 'INSUFFICIENT_PRIVILEGES') {
// User doesn't have permission to record
}
}