Esempio n. 1
0
        public static void VolumeUp()
        {
            if (System.Environment.OSVersion.Version.Major >= 6)
            {
                //
                // Use new vista volume apis
                //

                EndpointVolume epVol = new EndpointVolume();
                float vol = epVol.MasterVolume;
                epVol.MasterVolume = Math.Min(1, vol += 1.0f / VolumeSteps);
                epVol.Dispose();
            }
            else
            {
                //
                // Use older volume apis on XP
                //

                WinMMVolume.MixerInfo mi = WinMMVolume.GetMixerControls();
                WinMMVolume.AdjustVolume(mi, (mi.maxVolume - mi.minVolume) / VolumeSteps);
            }
        }
Esempio n. 2
0
        public static void VolumeDown()
        {
            if (System.Environment.OSVersion.Version.Major >= 6)
            {
                //
                // Use new vista volume apis
                //

                EndpointVolume epVol = new EndpointVolume();
                float          vol   = epVol.MasterVolume;
                epVol.MasterVolume = Math.Max(0, vol -= 1.0f / VolumeSteps);
                epVol.Dispose();
            }
            else
            {
                //
                // Use older volume apis on XP
                //

                WinMMVolume.MixerInfo mi = WinMMVolume.GetMixerControls();
                WinMMVolume.AdjustVolume(mi, -(mi.maxVolume - mi.minVolume) / VolumeSteps);
            }
        }