Skip to main content
Version: 3.x.x

Start and Stop - Android

This guide shows how to start and stop recording a room.

startRecording()​

room.startRecording() starts a recording of the room. It takes four parameters:

  • 1. webhookUrl: A URL your server exposes. VideoSDK calls it as the recording starts, stops or fails. See Webhooks and Events for the payloads.

  • 2. awsDirPath: The directory in your own bucket to store the recording in. Set up the bucket first, as shown in Configure Recording Storage.

  • 3. config: A RecordingConfig that defines how the room should be recorded. RecordingConfig and its value types (ConfigLayout, ConfigLayoutGrid, ConfigLayoutPriority, ConfigTheme, ConfigMode, ConfigQuality, ConfigOrientation) are in the live.videosdk.rtc.android.model package. A field left null takes the server's default.

  • 4. transcription: A PostTranscriptionConfig that transcribes the recording once it ends.

note
  • webhookUrl, awsDirPath, config and transcription all default to null, so pass only the ones you need, as named arguments. If awsDirPath is null, recordings are stored on VideoSDK's storage.
  • startRecording() and stopRecording() are suspend functions. Call them from a coroutine, such as lifecycleScope.launch (from androidx.lifecycle:lifecycle-runtime-ktx).
  • They return once the request is sent, not when the recording has started or stopped. Wait for onRecordingStateChanged to report RECORDING_STARTED or RECORDING_STOPPED.
  • If the server refuses the request, they throw VideoSDKException and report the same error on onError: 4011 (START_RECORDING_FAILED) for a start while a recording is already starting or running, 4012 (STOP_RECORDING_FAILED) for a stop with no recording running or one still starting.
  • Called before the room is joined, or while it is reconnecting, they do nothing and report 3035 (ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED) or 3065 (ERROR_ROOM_RECONNECTING) on onError instead of throwing.
// Layout Configuration
val layout = ConfigLayout(
type = ConfigLayoutGrid.GRID, // SPOTLIGHT | SIDEBAR, Default : GRID
priority = ConfigLayoutPriority.SPEAKER, // PIN, Default : SPEAKER
gridSize = 4, // MAX : 4
)

val config = RecordingConfig(
layout = layout,
// Theme of recording
theme = ConfigTheme.DARK, // LIGHT | DEFAULT
// `mode`: record video and audio, or audio only.
mode = ConfigMode.VIDEO_AND_AUDIO, // AUDIO, Default : VIDEO_AND_AUDIO
// Quality of recording, only applicable to VIDEO_AND_AUDIO mode.
// LOW (SD Recording) | MED (HD Recording) | HIGH (FHD Recording)
quality = ConfigQuality.HIGH,
// Orientation of the recording.
// LANDSCAPE : Record the room horizontally
// PORTRAIT : Record the room vertically (Best for mobile view)
orientation = ConfigOrientation.PORTRAIT, // LANDSCAPE, Default : LANDSCAPE
)

// Post Transcription Configuration
val prompt = "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
val summaryConfig = SummaryConfig(true, prompt)
val modelId = "raman_v1"
val transcription = PostTranscriptionConfig(true, summaryConfig, modelId)

lifecycleScope.launch {
try {
room!!.startRecording(config = config, transcription = transcription)
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "Start recording failed: ${e.code} ${e.name}")
}
}

stopRecording()​

  • room.stopRecording() stops the recording.

Example​

// keep track of recording: set it to true on RECORDING_STARTED
// and to false on RECORDING_STOPPED in onRecordingStateChanged
var recording = false

findViewById<View>(R.id.btnRecording).setOnClickListener { view: View? ->
lifecycleScope.launch {
try {
if (!recording) {
val config = RecordingConfig(
layout = ConfigLayout(ConfigLayoutGrid.GRID, ConfigLayoutPriority.SPEAKER, 4),
theme = ConfigTheme.DARK,
mode = ConfigMode.VIDEO_AND_AUDIO,
quality = ConfigQuality.HIGH,
orientation = ConfigOrientation.PORTRAIT,
)

// Post Transcription Configuration
val prompt = "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
val summaryConfig = SummaryConfig(true, prompt)
val modelId = "raman_v1"
val transcription = PostTranscriptionConfig(true, summaryConfig, modelId)

// Start Recording
// Leave out `webhookUrl`, `awsDirPath` or `transcription` if you don't need them.
room!!.startRecording("YOUR WEB HOOK URL", "AWS Directory Path", config, transcription)
} else {
// Stop Recording
room!!.stopRecording()
}
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "Recording request failed: ${e.code} ${e.name}")
}
}
}
important

To start recording automatically when a session begins, set recording in autoStartConfig when you create the room with the Create Room API.

API Reference​

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

Got a Question? Ask us on discord