我使用 linphone sdk,我想获取音频设备的列表,或者更确切地说是它们的类型和 driverName,但它以 {2: Audio, 3: Audio, 1: AAudio} 的样式输出 虽然如果你在ios上这样做,它通常会以{3:Speaker}的风格发出
这里我也想在android上做
代码:
val devices = core.audioDevices
val devicesMap: Map<Int, String> = devices.associateBy({ it.type.ordinal }, { it.driverName })
我不知道linphone sdk,但android中有一个名为AudioDeviceInfo的Api,它有可以满足你要求的方法。
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
for (AudioDeviceInfo device : devices) {
Log.d("Type",device.getType());
Log.d("Product Name",device.getProductName());
}
10; TECNO KD7 Build/QP1A.190711.020; wv) AppleWebKit/537.36(KHTML,如 Gecko)版本/4.0 Chrome/131.0.6778.135 Mobile Safari/537.36 OcIdWebView ({"os":"Android","osVersion":"29","app":"com.google .android.gms","appVersion":"244738000","样式