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

Record the Conference for Android

This tutorial guides how to add a recording feature to your conference application. We will use the RecordingService.

Start recording

1. To modify the layout, edit the main_activity.xml file, adding the following content for Step 6:

<LinearLayout ...>
    ...

    <!-- Step 6. Put the layout changes for the recording step here -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/start_recording"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="start recording" />

        <!-- Step 6.2 This layout will be upgraded in the stop recording step -->
    </LinearLayout>

</LinearLayout>

2. Modify the interface linking in the MainActivity class in MainActivity.java:

  • New method for MainActivity:
@OnClick(R.id.start_recording)
public void onStartRecording() {

}
  • Add the following code to the onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
    ...

    //adding the start recording in the flow
    add(views, R.id.start_recording);
    add(buttonsInConference, R.id.start_recording);
}

3. Add the following logic to the application:

  • Use the following implementation for onStartRecording:
public void onStartRecording() {
    VoxeetSDK.recording().start()
            .then((result, solver) -> {
            })
            .error((error_in) -> {
                String error_message = "Error";
                if (((ServerErrorException)error_in).error.error_code == 303) {
                    error_message = "Recording already started";
                }
                updateViews();
                Toast.makeText(MainActivity.this, error_message, Toast.LENGTH_SHORT).show();
            });
}
  • Add a handler for RecordingStatusUpdatedEvent:
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(RecordingStatusUpdatedEvent event) {
    String message = null;
    switch (event.recordingStatus) {
        case "RECORDING": message = "Recording started"; break;
        case "NOT_RECORDING": message = "Recording stopped"; break;
        default: break;
    }
    if (null != message)
        Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
}

Stop recording

1. To modify the layout, edit the main_activity.xml file, adding the following content for Step 6.2:

<LinearLayout ...>
...
<LinearLayout ...>
    ...

        <!-- Step 6.2 This layout will be upgraded in the stop recording step -->
        <Button
            android:id="@+id/stop_recording"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="stop recording" />

    </LinearLayout>

</LinearLayout>

2. Modify the interface linking in the MainActivity class in MainActivity.java:

  • New method for MainActivity:
@OnClick(R.id.stop_recording)
public void onStopRecording() {

}
  • Add the following code to the onCreate method:
@Override
protected void onCreate(Bundle savedInstanceState) {
    ...

    //adding the stop recording in the flow
    add(views, R.id.stop_recording);
    add(buttonsInConference, R.id.stop_recording);
}

3. Add the following logic to the application:

  • Use the following implementation for onStopRecording:
public void onStopRecording() {
    VoxeetSDK.recording().stop()
            .then((result, solver) -> {
            })
            .error(error());
}

Did this page help you?