Hello,
Starting with Android 6.0, you can get the available audio input and output devices using AudioDeviceInfo.
I'm using the following inline JAVA code to get the list of audio devices. For each in/out audiodevice device I get the name, id and type.
How can I set the audio in and audio out devices in AudioStreamer, using setPreferredDevice, available for both AudioRecord and AudioTrack?
Thank you.
Starting with Android 6.0, you can get the available audio input and output devices using AudioDeviceInfo.
I'm using the following inline JAVA code to get the list of audio devices. For each in/out audiodevice device I get the name, id and type.
B4X:
#If JAVA
import android.media.AudioManager;
import android.media.AudioDeviceInfo;
import android.content.Context;
public String[] getAudioInDevicesNames() {
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adi = audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
String[] s = new String[adi.length];
for (int i = 0; i < adi.length - 1; i++) {
s[i] = (String)adi[i].getProductName() + "," + adi[i].getId() + "," + adi[i].getType();
}
return s;
}
public String[] getAudioOutDevicesNames() {
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adi = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
String[] s = new String[adi.length];
for (int i = 0; i < adi.length - 1; i++) {
s[i] = (String)adi[i].getProductName() + "," + adi[i].getId() + "," + adi[i].getType();
}
return s;
}
#End If
How can I set the audio in and audio out devices in AudioStreamer, using setPreferredDevice, available for both AudioRecord and AudioTrack?
Thank you.