private void DeviceNotification_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { try { _defaultDeviceChanged = true; Trace.TraceInformation("Default device changed. New device: {0}, {1}", e.DataFlow.ToString(), e.Role.ToString()); switch (e.DataFlow) { case DataFlow.Capture: GetCapture(_isControllerMode, e.DeviceId); break; case DataFlow.Render: GetNewSoundOut(); break; } } catch (Exception exp) { Trace.TraceError(exp.Message); } finally { _defaultDeviceChanged = false; } }
private static void OnDefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { using (var enumerator = new MMDeviceEnumerator()) using (var mmDevice = enumerator.GetDevice(e.DeviceId)) { Console.WriteLine($"{mmDevice.FriendlyName} became default {e.Role} {e.DataFlow} device"); } }
private async void DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { if (!IsRunning) { return; } await Task.Run(SetupDefaultEndpoint).ConfigureAwait(false); }
private void DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { MMDevice device = MyMMDeviceEnumerator.GetDevice(e.DeviceId); if (device != null && e.Role == Role.Multimedia && e.DataFlow == DataFlow.Render) { Log.D($"Default Audio Device Changed to {device.FriendlyName}, Flow: {device.DataFlow}"); DefaultMmDevice = device; } }
private void HandleDefaultChanged(DefaultDeviceChangedEventArgs defaultChangedEvent) { if (defaultChangedEvent.IsDefaultEvent) { OnPropertyChanged("IsDefaultDevice"); } else if (defaultChangedEvent.IsDefaultCommunicationsEvent) { OnPropertyChanged("IsDefaultCommunicationsDevice"); } }
private void MMNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { if (e.DeviceId.Equals(DispositivoAtual) == false) { //Console.Write("Default Device changed to: "); //Console.WriteLine(e.DeviceId); DispositivoAtual = e.DeviceId; Listen(false); UpdateFromDefaultDevice(); Listen(true); } }
private void OnDefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { // For some reason this event triggers twice. // We keep track of the previous state, and only raise the event if // we are now the default device and were not before. if (IsDefault && !_wasDefault) { _wasDefault = true; DeviceDefaultChanged?.Invoke(this); } else { _wasDefault = false; } }
private void MMNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { if (e.DeviceId == _lastDefaultDeviceChanged) { return; } _lastDefaultDeviceChanged = e.DeviceId; if (CurrentSoundOutDevice?.Id == WindowsDefaultId) { Application.Current.Dispatcher.BeginInvoke(new Action(OnInvalidateSoundOut)); } Application.Current.Dispatcher.BeginInvoke(new Action(UpdateDefaultAudioDevice)); }
private void OnDefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { if (e.DataFlow != Flow.ToDataFlow()) { return; } bool newDefault = e.DeviceId == DeviceId; if (IsDefault != newDefault) { AppLogging.DebugLog(nameof(OnDefaultDeviceChanged), DeviceId, newDefault.ToString()); IsDefault = newDefault; DeviceDefaultChanged?.Invoke(this); } }
void client_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { if (Settings.SoundOutDeviceID == "-0" && e.DeviceID != _currentDeviceId) { _currentDeviceId = e.DeviceID; Thread t = new Thread(() => { Thread.Sleep(100); Application.Current.Dispatcher.Invoke(UpdateSoundOut); }) { IsBackground = true }; t.Start(); } _client.Dispose(); }
private void MMNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { // Only try to resume on new default device if not stopped if (this.canStop) { this.defaultDeviceChangedTimer.Stop(); this.pauseAfterSwitchingDefaultDevice = !this.canPause; if (this.currentTime == null) { this.currentTime = this.GetCurrentTime(); this.SuspendSoundOut(); } this.defaultDeviceChangedTimer.Start(); } }
private void _mmNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { if (e.DeviceId == _lastDefaultDeviceChanged) { return; } _lastDefaultDeviceChanged = e.DeviceId; if (AnyListenSettings.Instance.Config.SoundOutDeviceID == DefaultDevicePlaceholder && e.DeviceId != _currentDeviceId) { if (RefreshSoundOut != null) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(OnRefreshSoundOut)); } } Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateDefaultAudioDevice)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="aEvent"></param> public void OnDefaultMultiMediaDeviceChanged(object sender, DefaultDeviceChangedEventArgs aEvent) { if (aEvent != null && (aEvent.DataFlow == DataFlow.Render && (aEvent.Role == Role.Multimedia || aEvent.Role == Role.Console))) { if (_mMdevice != null) { _mMdevice.Dispose(); _mMdevice = null; } if (_mMdeviceEnumerator != null) { _mMdeviceEnumerator.Dispose(); _mMdeviceEnumerator = null; } Stop(); CreateDevice(OnDefaultMultiMediaDeviceChanged, OnVolumeNotification); //ResetAudioManagerThreadSafe(); } }
private void HandleDefaultChanged(DefaultDeviceChangedEventArgs defaultChangedEvent) { if (defaultChangedEvent.IsDefaultEvent) OnPropertyChanged("IsDefaultDevice"); else if (defaultChangedEvent.IsDefaultCommunicationsEvent) OnPropertyChanged("IsDefaultCommunicationsDevice"); }
private void MmNotificationClient_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) { this.audioDevicesChangedTimer.Stop(); this.audioDevicesChangedTimer.Start(); }
private void AudioEndpointDevice_OnVolumeNotification(object sender, DefaultDeviceChangedEventArgs e) { // Not used // here }
/// <summary> /// Get new default device /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MMN_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) => GetMMD();
private void CoreTestMainWindow_DefaultDeviceChanged(object sender, DefaultDeviceChangedEventArgs e) => GetMMD();