NEWDolby Interactivity APIs are now the Dolby.io Communications APIs Learn More >
X

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: 100, y: stopScreenShareButton.frame.origin.y + stopScreenShareButton.frame.height + 16, width: 100, height: 30)
    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!) {
    ...
        // 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: 200, y: stopScreenShareButton.frame.origin.y + stopScreenShareButton.frame.height + 16, width: 100, height: 30)
    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 */
        }
    }
}

...


Did this page help you?