Skip to main content
Version: 0.1.x

Change Input/Output Device - Android

During the meeting at any point a participant wishes to switch his/her audio or video device, it can be done using the below mentioned methods.

Changing Input/Output Audio Device

getMics()

  • The getMics() method will return a list of all available microphones that are connected to the mobile device.

  • This method will return a Set of AppRTCAudioManager.AudioDevice.

  private fun getMics(): MutableSet<AppRTCAudioManager.AudioDevice>? {
val mics= meeting!!.mics
return mics // returns all connected mics
}

changeMic()

  • Participant can change the audio device using changeMic(AppRTCAudioManager.AudioDevice device) method of Meeting class.

  • Parameters that can be passed to changeMic are

    Audio DevicesUsage
    AppRTCAudioManager.AudioDevice.BLUETOOTHFor Bluetooth Device.
    AppRTCAudioManager.AudioDevice.WIRED_HEADSETFor Wired Handset Device.
    AppRTCAudioManager.AudioDevice.SPEAKER_PHONEFor Inbuilt - Speaker Device
    AppRTCAudioManager.AudioDevice.EARPIECEFor Earpiece Device
  • When participant changes the Mic, AppRTCAudioManager.AudioManagerEvents() is triggered which can be set to Meeting class by using setAudioDeviceChangeListener().

Example


btnChangeMic!!.setOnClickListener { _: View? ->
// Change Mic during Meeting
meeting!!.changeMic(AppRTCAudioManager.AudioDevice.BLUETOOTH)
}

private fun setAudioDeviceListeners() {
meeting!!.setAudioDeviceChangeListener(object : AudioManagerEvents {
override fun onAudioDeviceChanged(
selectedAudioDevice: AppRTCAudioManager.AudioDevice,
availableAudioDevices: Set<AppRTCAudioManager.AudioDevice>
) {
when (selectedAudioDevice) {
AppRTCAudioManager.AudioDevice.BLUETOOTH ->
Toast.makeText(this@MainActivity, "Selected AudioDevice: BLUETOOTH", Toast.LENGTH_SHORT).show()

AppRTCAudioManager.AudioDevice.WIRED_HEADSET ->
Toast.makeText(this@MainActivity, "Selected AudioDevice: WIRED_HEADSET", Toast.LENGTH_SHORT).show()

AppRTCAudioManager.AudioDevice.SPEAKER_PHONE ->
Toast.makeText(this@MainActivity, "Selected AudioDevice: SPEAKER_PHONE", Toast.LENGTH_SHORT).show()

AppRTCAudioManager.AudioDevice.EARPIECE ->
Toast.makeText(this@MainActivity, "Selected AudioDevice: EARPIECE", Toast.LENGTH_SHORT).show()
}
}
})
}

override fun onCreate(savedInstanceState: Bundle?) {
// ...
setAudioDeviceListeners()
}
  • To use Bluetooth device, you must declare BLUETOOTH permission in AndroidManifest.xml file.
<manifest ... >
//...
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
</manifest>

Changing Camera Input Device

changeWebcam()

  • By using changeWebcam() function, a participant can stream from front / rear camera during the meeting.

Example

  btnWebcam!!.setOnClickListener {
// Change Webcam during Meeting
meeting!!.changeWebcam()
}

API Reference

The API references for all the methods and events utilised in this guide are provided below.

Got a Question? Ask us on discord