Record the Conference for iOS
This tutorial guides how to add a recording feature to your conference application. We will use the RecordingService
.
Start recording
Add UI for starting recording in ViewController.swift
.
1. In ViewController.swift, add a variable to the ViewController
class to refer to the user interface element that will be created in step 2.
class ViewController: UIViewController {
...
// Conference UI.
var startRecordingButton: UIButton!
...
}
2. Modify initConferenceUI
to extend the user interface and enable & disable the startRecordingButton
as appropriate.
...
func initConferenceUI() {
...
// Start recording button.
startRecordingButton = UIButton(type: .system) as UIButton
startRecordingButton.frame = CGRect(
x: margin,
y: startScreenShareButton.frame.origin.y + startScreenShareButton.frame.height + margin,
width: buttonWidth,
height: buttonHeight
)
startRecordingButton.backgroundColor = startRecordingButton.tintColor
startRecordingButton.layer.cornerRadius = 5
startRecordingButton.isEnabled = false
startRecordingButton.isSelected = true
startRecordingButton.setTitle("START RECORD", for: .normal)
startRecordingButton.addTarget(self, action: #selector(startRecordingAction), for: .touchUpInside)
self.view.addSubview(startRecordingButton)
}
...
@objc func startButtonAction(sender: UIButton!) {
// Create a conference room with an alias.
...
options.params.liveRecording = true /* enable recordings to appear immediately in dashboard monitor */
...
// Join the conference with its id.
VoxeetSDK.shared.conference.join(conference: conference, success: { response in
...
self.startRecordingButton.isEnabled = true /* Update startRecording button state */
}, fail: { error in })
}, fail: { error in })
}
@objc func leaveButtonAction(sender: UIButton!) {
VoxeetSDK.shared.conference.leave { error in
...
self.startRecordingButton.isEnabled = false /* Update startRecording button state */
}
}
3. Add a method to start recording.
...
@objc func startRecordingAction(sender: UIButton!) {
VoxeetSDK.shared.recording.start { error in
if error == nil {
self.startRecordingButton.isEnabled = false /* Update startRecording button state */
}
}
}
...
Stop recording
dd UI for stopping video in ViewController.swift
.
1. In ViewController.swift, add a variable to the ViewController
class to refer to the user interface element that will be created in step 2.
class ViewController: UIViewController {
...
// Conference UI.
var stopRecordingButton: UIButton!
...
}
2. Modify initConferenceUI
to extend the user interface and enable & disable the stopRecordingButton
as appropriate.
...
func initConferenceUI() {
...
// Stop recording button.
stopRecordingButton = UIButton(type: .system) as UIButton
stopRecordingButton.frame = CGRect(
x: startRecordingButton.frame.origin.x + startRecordingButton.frame.width + margin,
y: startRecordingButton.frame.origin.y,
width: buttonWidth,
height: buttonHeight
)
stopRecordingButton.backgroundColor = stopRecordingButton.tintColor
stopRecordingButton.layer.cornerRadius = 5
stopRecordingButton.isEnabled = false
stopRecordingButton.isSelected = true
stopRecordingButton.setTitle("STOP RECORD", for: .normal)
stopRecordingButton.addTarget(self, action: #selector(stopRecordingAction), for: .touchUpInside)
self.view.addSubview(stopRecordingButton)
}
...
@objc func leaveButtonAction(sender: UIButton!) {
VoxeetSDK.shared.conference.leave { error in
...
self.stopRecordingButton.isEnabled = false /* Update stopRecording button state */
}
}
@objc func startRecordingAction(sender: UIButton!) {
VoxeetSDK.shared.recording.start { error in
if error == nil {
...
self.stopRecordingButton.isEnabled = true /* Update stopRecording button state */
}
}
}
3. Add a method to stop the recording.
...
@objc func stopRecordingAction(sender: UIButton!) {
VoxeetSDK.shared.recording.stop { error in
if error == nil {
self.startRecordingButton.isEnabled = true /* Update startRecording button state */
self.stopRecordingButton.isEnabled = false /* Update stopRecording button state */
}
}
}
...
Updated over 1 year ago