• c#语音报时(含完整的声音资源文件).rar


            private void btnBaoshi_Click(object sender, EventArgs e)
            {
                try
                {
                    System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(PlayTime));
                    thread.Start();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
    
            private static void PlayTime()
            {
                System.Media.SoundPlayer sndPlayer;
    
                string sound = @"VoiceTimeTIMENOW.wav";
                sndPlayer = new System.Media.SoundPlayer(sound);
                sndPlayer.PlaySync();
    
                if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 6)
                    sound = @"VoiceTimeAM0.wav";
                else if (DateTime.Now.Hour >= 6 && DateTime.Now.Hour < 12)
                    sound = @"VoiceTimeAM1.wav";
                else if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18)
                    sound = @"VoiceTimePM.wav";
                else
                    sound = @"VoiceTimeEM.wav";
                sndPlayer = new System.Media.SoundPlayer(sound);
                sndPlayer.PlaySync();
    
                int hours = DateTime.Now.Hour;
    
                if (hours > 12)
                    hours = hours - 12;
    
                if (hours < 10)
                    sound = @"VoiceTimeT0" + hours + ".wav";
                else
                    sound = @"VoiceTimeT" + hours + ".wav";
    
                sndPlayer = new System.Media.SoundPlayer(sound);
                sndPlayer.PlaySync();
    
                sound = @"VoiceTimePOINT.wav";
                sndPlayer = new System.Media.SoundPlayer(sound);
                sndPlayer.PlaySync();
    
                int min = DateTime.Now.Minute;
                if (min >= 0 && min < 10)
                    sound = @"VoiceTimeT00.wav";
                else if (min >= 10 && min < 20)
                    sound = @"VoiceTimeT10.wav";
                else if (min >= 20 && min < 30)
                    sound = @"VoiceTimeT20.wav";
                else if (min >= 30 && min < 40)
                    sound = @"VoiceTimeT30.wav";
                else if (min >= 40 && min < 50)
                    sound = @"VoiceTimeT40.wav";
                else if (min >= 50 && min < 60)
                    sound = @"VoiceTimeT50.wav";
                sndPlayer = new System.Media.SoundPlayer(sound);
                sndPlayer.PlaySync();
    
                min = min % 10;
                if (min != 0)
                {
                    sound = @"VoiceTimeT0" + min + ".wav";
                    sndPlayer = new System.Media.SoundPlayer(sound);
                    sndPlayer.PlaySync();
                }
    
                sound = @"VoiceTimeMIN.wav";
                sndPlayer = new System.Media.SoundPlayer(sound);
                sndPlayer.PlaySync();
    
                if (sndPlayer != null)
                {
                    sndPlayer.Dispose();
                    sndPlayer = null;
                }
            }
    

      

    c#语音报时(含完整的声音资源文件).rar

  • 相关阅读:
    哈尔特征Haar
    【python】发送post请求
    【svn】SSL error: A TLS warning alert has been received的解决方法
    【python】tarfile的路径问题
    【python】nuitka封装python
    【linux】scp命令
    【mongo】聚合相关资料
    【python】with的实现方法
    【mongo】mongoVUE使用
    【http】四种常见的 POST 提交数据方式
  • 原文地址:https://www.cnblogs.com/chengulv/p/3775954.html
Copyright © 2020-2023  润新知