Recording

In certain situations, you may need to record a call and share the recording with the participants. The Stream Video SDK supports this functionality via the Call recording API.

Start and Stop Recording

To start recording, we simply invoke call.startRecording(). To stop recording, we use call.stopRecording().

call.startRecording()
call.stopRecording()

The call.state.recording property of type StateFlow<Boolean> will be updated when call recording starts/stops.

val isRecording by call.state.recording.collectAsStateWithLifecycle() // Use to update the UI

Get a List of Recordings

You can retrieve recordings by using call.listRecordings(). If the query is successful, result will contain a list of recordings, each containing information about the filename, URL and the start and end times. You can use the URL to show the recording in a video player.

val result = call.listRecordings()

result
    .onSuccess { response: ListRecordingsResponse ->
        response.recordings.forEach { recording: CallRecording ->
            Log.d(TAG, recording.filename)
            Log.d(TAG, recording.url)
            Log.d(TAG, recording.startTime.toString())
            Log.d(TAG, recording.endTime.toString())
        }
    }
    .onError { error: Error ->
        Log.e(TAG, "Failure: ${error.message}")
    }

Listening to Recording Events

You can listen to recording-related events and change to UI accordingly.

val sub = call.subscribeFor(
    CallRecordingStartedEvent::class.java,
    CallRecordingStoppedEvent::class.java,
    CallRecordingReadyEvent::class.java,
    CallRecordingFailedEvent::class.java
) {
    Log.e(TAG, "Event type: ${it.getEventType()}")
}

// stop listening
sub.dispose()

Read more about subscribing to events on the events page.

© Getstream.io, Inc. All Rights Reserved.