/// <summary> /// Determines whether the specified application is muted. /// </summary> /// <param name="name"> /// The name of the application. /// </param> public static bool?GetApplicationMute(string name) { var volume = ComImports.GetVolumeObject(name); if (volume == null) { return(null); } _ = volume.GetMute(out var mute); return(mute); }
/// <summary> /// Retrieves the volume of the specified application. /// </summary> /// <param name="name"> /// The name of the application. /// </param> public static float?GetApplicationVolume(string name) { var volume = ComImports.GetVolumeObject(name); if (volume == null) { return(null); } _ = volume.GetMasterVolume(out var level); return(level * 0x64); }
/// <summary> /// Mutes the volume of the specified application. /// </summary> /// <param name="name"> /// The name of the application to change. /// </param> /// <param name="mute"> /// true to mute; otherwise, false to unmute. /// </param> public static void SetApplicationMute(string name, bool mute) { var volume = ComImports.GetVolumeObject(name); if (volume == null) { return; } var guid = Guid.Empty; _ = volume.SetMute(mute, ref guid); }
/// <summary> /// Sets the volume of the specified application. /// </summary> /// <param name="name"> /// The name of the application to change. /// </param> /// <param name="level"> /// The volume level to set. /// </param> public static void SetApplicationVolume(string name, float level) { var volume = ComImports.GetVolumeObject(name); if (volume == null) { return; } var guid = Guid.Empty; _ = volume.SetMasterVolume(level / 0x64, ref guid); }