Вот код для получения микрофона из моей системы.
Код: Выделить всё
namespace CallDetector
{
public sealed partial class MainPage : Page
{
private DispatcherTimer timer;
private MediaCapture mediaCapture;
public MainPage()
{
this.InitializeComponent();
StartMicrophoneStatusCheckTimer();
}
private void StartMicrophoneStatusCheckTimer()
{
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(5);
timer.Tick += Timer_Tick;
timer.Start();
}
private async void Timer_Tick(object sender, object e)
{
await CheckMicrophoneStatus();
}
private async Task CheckMicrophoneStatus()
{
var microphoneDevice = await GetMicrophoneDeviceAsync();
if (microphoneDevice != null && microphoneDevice.IsEnabled)
{
var msg = new MessageDialog($"Microphone device found: {microphoneDevice.Name}");
await msg.ShowAsync();
}
else
{
var msge = new MessageDialog("No microphone device found.");
await msge.ShowAsync();
}
}
private static async Task GetMicrophoneDeviceAsync()
{
var microphoneSelector = MediaDevice.GetAudioCaptureSelector();
var microphoneDevices = await DeviceInformation.FindAllAsync(microphoneSelector);
return microphoneDevices.FirstOrDefault();
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/764 ... -is-in-use