none
wpf调节系统音量 RRS feed

答案

  •        private MMDevice dev;
            int gg = 0;
    
            public Form1()
            {
                InitializeComponent();
                timer1.Enabled = true;
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
    
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                gg = (int)(dev.AudioEndpointVolume.MasterVolumeLevelScalar * 100);
                this.progressBar1.Value = gg;
    
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
    
                if (dev.AudioEndpointVolume.Mute == true)
                {
                    dev.AudioEndpointVolume.Mute = false;
                }
                else
                { 
                    dev.AudioEndpointVolume.Mute = true;
                }
    
    
                
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                dev.AudioEndpointVolume.VolumeStepUp();
               
                //You may access Volume Step && StepCount
                uint step = dev.AudioEndpointVolume.StepInformation.Step;
                uint stepcount = dev.AudioEndpointVolume.StepInformation.StepCount;
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                dev.AudioEndpointVolume.VolumeStepDown();
    
                //You may access Volume Step && StepCount
                uint step = dev.AudioEndpointVolume.StepInformation.Step;
                uint stepcount = dev.AudioEndpointVolume.StepInformation.StepCount;
            }
    

    2014年3月14日 5:26

全部回复

  •        private MMDevice dev;
            int gg = 0;
    
            public Form1()
            {
                InitializeComponent();
                timer1.Enabled = true;
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
    
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                gg = (int)(dev.AudioEndpointVolume.MasterVolumeLevelScalar * 100);
                this.progressBar1.Value = gg;
    
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
    
                if (dev.AudioEndpointVolume.Mute == true)
                {
                    dev.AudioEndpointVolume.Mute = false;
                }
                else
                { 
                    dev.AudioEndpointVolume.Mute = true;
                }
    
    
                
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                dev.AudioEndpointVolume.VolumeStepUp();
               
                //You may access Volume Step && StepCount
                uint step = dev.AudioEndpointVolume.StepInformation.Step;
                uint stepcount = dev.AudioEndpointVolume.StepInformation.StepCount;
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
                dev = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                dev.AudioEndpointVolume.VolumeStepDown();
    
                //You may access Volume Step && StepCount
                uint step = dev.AudioEndpointVolume.StepInformation.Step;
                uint stepcount = dev.AudioEndpointVolume.StepInformation.StepCount;
            }
    

    2014年3月14日 5:26
  • 下载这个DLL : CoreAudioApi.dll
    2014年3月14日 5:27
  • 下载这个DLL : CoreAudioApi.dll

    请问CoreAudioApi.dll是哪个版本的,我下了是3.5.0.0版本,没有
    dev.AudioEndpointVolume
    该方法

    已经从codeprect下载了,2.0。0.0版本的
    • 已编辑 skczjun 2014年3月16日 5:50 解决
    2014年3月16日 1:50