Uploading
Our Recorder
includes support for uploading the video as it is being recorded, enabling a seamless
experience where the video is immediately available to other users after recording, as long as the network
connection is fast enough.
The upload-while-recording is enabled by default and can be controlled using the uploadParams
field.
The field accepts an UploadParams
as described in the upload documentation.
Note that it should not be changed while video is being recorded.
recorder.uploadParams = nil // do not upload while recording
recorder.uploadParams = .init(...) // upload while recording
If uploadParams
is not null (default), as soon as recording starts, the SDK will also start uploading it.
The user is free to pause and resume recording (for example, to switch camera in between), and the
upload will be resumed as well automatically.
Configuring the upload
The upload process will generate a playable Video
object. Just like Video
s created outside of
the recorder (through VideoKit.uploads()
), you have the option to set the
video tags
, title
and metadata
, by just passing them to the recorder:
recorder.uploadParams = .init(
title: "My title",
tags: myTags,
metadata: myMetadata
)
Handling results
When uploadParams
is not null, the final Recording
will contain extra information:
class CustomRecorderObserver : RecorderObserver {
func recorderResult(_ result: Recording) {
// Since upload request was set, the final record contains an Upload object.
// Use this object with the upload manager (VideoKit.uploads()) to listen for updates.
let upload: Upload = recording.upload!
// Since upload request was set, we also have a Video object available that is ready to be
// played with the player SDK, even if upload has not finished yet.
let video: Video = recording.video!
}
}