Configuring Audio, Video Input and Output devices - Twilio
Register for SIGNAL by 8/31 for $250 off. Register now.

Configuring Audio, Video Input and Output devices

In this guide we’ll show you how to configure Audio,Video input and output devices from your Twilio Video Rooms API application. Taking advantage of the ability to control input and output devices lets you build a better end user experience.

Selecting a specific Video Input

The CameraCapturer class is used to provide video frames for a LocalVideoTrack from a given CameraCapturer.CameraSource.

// Share your camera
CameraCapturer cameraCapturer = new CameraCapturer(context, CameraSource.FRONT_CAMERA);
LocalVideoTrack localVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer);

// Render camera to a view
VideoView primaryVideoView = (VideoView) findViewById(;

// Mirror front camera

// Render camera to view

// Switch the camera source
CameraSource cameraSource = cameraCapturer.getCameraSource();
primaryVideoView.setMirror(cameraSource == CameraSource.BACK_CAMERA);

Selecting a specific Audio input

The Twilio Video Android SDK does not officially support switching the AudioSource and just defaults to the native Android API MediaRecorder.AudioSource.VOICE_COMMUNICATION

Selecting a specific Audio output

Using the AudioManager class provided by Android, you can specify if audio is routed through the headset or speaker.

// Get AudioManager
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

// Route audio through speaker

// Route audio through headset

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.