示例#1
0
        public DgMic()
        {
            MMDeviceEnumerator enumerator = new MMDeviceEnumerator();

            _devices = enumerator.EnumerateAudioEndpoints(EDataFlow.ECapture,
                                                          EDeviceState.DeviceStateActive);
            _oldState = DgMicStates.Unmuted;
            _count    = _devices.Count;

            for (int i = 0; i < _count; i++)
            {
                _devices[i].AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification;
            }
        }
示例#2
0
文件: DgMic.cs 项目: sco3tt/dgMicMute
        public void SetMicStateTo(DgMicStates state)
        {
            // Removed this check so the current state remains the responsibility of the caller (i.e. NotifyIconViewModel).
            // This class now just does whatever it is told to do.
            //if (_oldState == state) return;

            for (int i = 0; i < _count; i++)
            {
                try
                {
                    _devices[i].AudioEndpointVolume.Mute = state == DgMicStates.Muted;
                }
                catch
                {
                    //We don't care about it beeing set or not.
                    //Sometimes, it doesn't work.
                }
            }
        }
示例#3
0
        public void SetMicStateTo(DgMicStates state)
        {
            if (_oldState == state)
            {
                return;
            }

            _oldState = state;

            for (int i = 0; i < _count; i++)
            {
                try
                {
                    _devices[i].AudioEndpointVolume.Mute = state == DgMicStates.Muted;
                }
                catch
                {
                    //We don't care about it beeing set or not.
                    //Sometimes, it doesn't work.
                }
            }
        }