Implementations
We provide two RecorderProtocol
implementations that you can choose from depending on your case.
Using them is a bit different but they all share the same functionality from the RecorderProtocol
protocol.
- A default implementation called
Recorder
- A UIKit-specific implementation called
RecorderViewController
. It conforms to the recorder protocol by delegating to aRecorder
under the hood.
The default recorder
Recorder
is the low level implementation that, unlike the others, is detached from
the UI. You will typically hold the default instance in the "view model" layer of your app.
let recorder = Recorder(
audioOptions: ...,
videoOptions: ...,
uploadParams: ...
)
Attaching to the UI
In order to show the UI you must add the preview layer, Recorder.videoPreviewLayer
to some View in your hierarchy:
view.layer.addSublayer(recorder.videoPreviewLayer)
The recorder ViewController
RecorderViewController
is a UIKit-based implementation of our recorder protocol, which does what was stated above - adds the preview layer as a child element covering the full size of the controller.
let recorder = RecorderViewController(
audioOptions: ...,
videoOptions: ...,
uploadParams: ...
)
After creating the view controller, it can be added to your hierarchy and it will show the camera preview.
SwiftUI
We don't offer any SwiftUI utility at the moment, but it is trivial to implement a SwiftUI recorder based on RecorderViewController
using UIViewControllerRepresentable
.