func startRecording() {
Task {
try await call.startRecording()
}
}Recording
Call's recording features
In some cases, you want to be able to record a meeting and share the recording with the participants later on. The StreamVideo SDK has support for this use-case.
In order to support this feature, you will need to use the Call's recording features, available after you join a call.
Recording state
The recording state of the call is available via the CallViewModel's recordingState published property. It's an enum, which has the following values:
noRecording- default value, there's no recording on the call.requested- recording was requested by the current user.recording- recording is in progress.
If you are not using our CallViewModel, you can also listen to this state via the Call's property recordingState.
Start a recording
To start a recording, you need to call the startRecording method of the call:
This will change the current recording state of the call to requested. Since it takes several seconds before the recording is started, it's best to handle this state by presenting a progress indicator to provide a better user experience.
After the recording is started, the recordingState changes to recording.
Stop a recording
To stop a recording, you need to call the stopRecording method of the Call:
func stopRecording() {
Task {
try await call.stopRecording()
}
}This will change the current recording state of the call to noRecording.
Recording events
You can listen to the recording events and show visual indications to the users based on these events, by subscribing to the async stream of the recordingEvents:
func subscribeToRecordingEvents() {
Task {
for await event in call.subscribe() {
switch event {
case .typeCallRecordingStartedEvent(let recordingStartedEvent):
log.debug("received an event \(recordingStartedEvent)")
/* handle recording event */
case .typeCallRecordingStoppedEvent(let recordingStoppedEvent):
log.debug("received an event \(recordingStoppedEvent)")
/* handle recording event */
default:
break
}
}
}
}Search recordings
You can search for recordings in a video call, using the Call's listRecordings method:
func loadRecordings() {
Task {
self.recordings = try await call.listRecordings()
}
}This will return a list of recordings, that contains information about the filename, URL, as well as the start and end time. You can use the URL to present the recording in a player. Here's an example in SwiftUI:
import SwiftUI
import StreamVideo
import AVKit
struct PlayerView: View {
let recording: CallRecording
var body: some View {
Group {
if let url = URL(string: recording.url) {
VideoPlayer(player: AVPlayer(url: url))
} else {
Text("Video can't be loaded")
}
}
}
}Recording Storage
Recordings are stored according to your Stream dashboard configuration. By default, recordings are stored on Stream's servers and are available for download via the URL provided in the CallRecording object.
You can also configure external storage (such as S3) in your dashboard settings for more control over where recordings are stored.
Recording Settings
When starting a recording, you can optionally specify custom settings. The recording configuration is typically set at the call type level in your dashboard, but can be customized per call if needed.
Recording properties available in CallRecording:
filename- The name of the recording fileurl- The URL to download/stream the recordingstartTime- When the recording startedendTime- When the recording ended