Commit 40f9f63
Enable preferred audio input device selection on Android
Add PreferredDevice property to BaseOptions for Android, allowing
consumers to select a specific audio input device (e.g. Bluetooth
headset, USB microphone) via AudioDeviceInfo.
Changes:
- Add BaseOptions.android.cs with PreferredDevice property typed as
AudioDeviceInfo from Android.Media
- Apply SetPreferredDevice on both AudioRecord and MediaRecorder after
creation, before starting recording
- Guarded with OperatingSystem.IsAndroidVersionAtLeast(23) since the
API requires Android Marshmallow (API 23+)
Usage:
var audioManager = (AudioManager)context.GetSystemService(Context.AudioService);
var btDevice = audioManager.GetDevices(GetDevicesTargets.Inputs)
.FirstOrDefault(d => d.Type == AudioDeviceType.BluetoothSco);
var recorder = audioManager.CreateRecorder(new AudioRecorderOptions
{
PreferredDevice = btDevice
});
Companion to #208 which adds the equivalent iOS/macCatalyst support.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 1dd3d29 commit 40f9f63
2 files changed
Lines changed: 34 additions & 0 deletions
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
137 | 143 | | |
138 | 144 | | |
139 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
140 | 152 | | |
141 | 153 | | |
142 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments