我正在使用CoreAudioApi,我有一个问题,我希望在一天的指定时间静音/取消静音我的电脑音量。当我把静音/取消静音放在一个按钮上就可以了......但我想按下按钮启动计时器,api应该在指定的时间自动运行。
这只是一个测试代码,我不能让它工作它符文,但它不会静音/解决,但(":")是"闪烁"因为它应该......
private void timer1_Tick(object sender, EventArgs e)
{
MMDeviceEnumerator devEnum = new MMDeviceEnumerator();
MMDevice defaultDevice = devEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
hr = DateTime.UtcNow.Hour;
min = DateTime.UtcNow.Minute;
sec = DateTime.UtcNow.Second;
if (hr > 12)
hr -= 12;
if (sec % 2 == 0)
{
lblTime.Text = hr+1 + ":" + min + ":" + sec;
}
else
{
lblTime.Text = hr+1 + " " + min + " " + sec;
}
if (hr == 13 && min == 37 && sec == 0)
{
defaultDevice.AudioEndpointVolume.Mute = true;
}
else if (hr == 13 && min == 37 && sec == 5)
{
defaultDevice.AudioEndpointVolume.Mute = false;
}
else if (hr == 13 && min == 37 && sec == 10)
{
defaultDevice.AudioEndpointVolume.Mute = true;
}
}