public static void SetMasterVolumeMute(bool isMuted) { IAudioEndpointVolume audioEndpointVolume = null; try { audioEndpointVolume = GetMasterVolumeObject(); audioEndpointVolume?.SetMute(isMuted, Guid.Empty); } finally { if (audioEndpointVolume != null) { Marshal.ReleaseComObject(audioEndpointVolume); } } }
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); } } }
/// <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); } } }
/// <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); } } }
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); } } }
/// <summary> /// Set Mute /// </summary> /// <param name="v"></param> public void SetMuted(bool v) { _audioEndpointVolume.SetMute(v, Guid.Empty); }