Ejemplo n.º 1
0
        public static void SetMasterVolumeMute(bool isMuted)
        {
            IAudioEndpointVolume audioEndpointVolume = null;

            try
            {
                audioEndpointVolume = GetMasterVolumeObject();
                audioEndpointVolume?.SetMute(isMuted, Guid.Empty);
            }
            finally
            {
                if (audioEndpointVolume != null)
                {
                    Marshal.ReleaseComObject(audioEndpointVolume);
                }
            }
        }
Ejemplo n.º 2
0
        public static void SetMasterVolumeMute(bool isMuted)
        {
            IAudioEndpointVolume masterVol = null;

            try
            {
                masterVol = GetMasterVolumeObject();
                if (masterVol == null)
                {
                    return;
                }

                masterVol.SetMute(isMuted, Guid.Empty);
            }
            finally
            {
                if (masterVol != null)
                {
                    Marshal.ReleaseComObject(masterVol);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Switches between the master volume mute states depending on the current state
        /// </summary>
        /// <returns>the current mute state, true if the volume was muted, false if unmuted</returns>
        public static void DisableMicrophone()
        {
            IAudioEndpointVolume masterVol = null;

            try
            {
                masterVol = GetMasterVolumeObject();
                if (masterVol == null)
                {
                    return;
                }

                masterVol.SetMute(true, Guid.Empty);
            }
            finally
            {
                if (masterVol != null)
                {
                    Marshal.ReleaseComObject(masterVol);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Switches between the master volume mute states depending on the current state
        /// </summary>
        /// <returns>the current mute state, true if the volume was muted, false if unmuted</returns>
        public static bool ToggleMasterVolumeMute()
        {
            IAudioEndpointVolume masterVol = null;

            try {
                masterVol = GetMasterVolumeObject();
                if (masterVol == null)
                {
                    return(false);
                }

                bool isMuted;
                masterVol.GetMute(out isMuted);
                masterVol.SetMute(!isMuted, Guid.Empty);

                return(!isMuted);
            } finally {
                if (masterVol != null)
                {
                    Marshal.ReleaseComObject(masterVol);
                }
            }
        }
Ejemplo n.º 5
0
        public static bool ToggleMasterVolumeMute()
        {
            IAudioEndpointVolume audioEndpointVolume = null;

            try
            {
                audioEndpointVolume = GetMasterVolumeObject();
                if (audioEndpointVolume == null)
                {
                    return(false);
                }
                audioEndpointVolume.GetMute(out bool isMuted);
                audioEndpointVolume.SetMute(!isMuted, Guid.Empty);
                return(!isMuted);
            }
            finally
            {
                if (audioEndpointVolume != null)
                {
                    Marshal.ReleaseComObject(audioEndpointVolume);
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Set Mute
 /// </summary>
 /// <param name="v"></param>
 public void SetMuted(bool v)
 {
     _audioEndpointVolume.SetMute(v, Guid.Empty);
 }