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

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 = @”VoiceTime\TIMENOW.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
if (DateTime.Now.Hour = 0 DateTime.Now.Hour 6)
sound = @”VoiceTime\AM0.wav”;
else if (DateTime.Now.Hour = 6 DateTime.Now.Hour 12)
sound = @”VoiceTime\AM1.wav”;
else if (DateTime.Now.Hour = 12 DateTime.Now.Hour 18)
sound = @”VoiceTime\PM.wav”;
else
sound = @”VoiceTime\EM.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
int hours = DateTime.Now.Hour;
if (hours 12)
hours = hours – 12;
if (hours 10)
sound = @”VoiceTime\T0″ + hours + “.wav”;
else
sound = @”VoiceTime\T” + hours + “.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
sound = @”VoiceTime\POINT.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
int min = DateTime.Now.Minute;
if (min = 0 min 10)
sound = @”VoiceTime\T00.wav”;
else if (min = 10 min 20)
sound = @”VoiceTime\T10.wav”;
else if (min = 20 min 30)
sound = @”VoiceTime\T20.wav”;
else if (min = 30 min 40)
sound = @”VoiceTime\T30.wav”;
else if (min = 40 min 50)
sound = @”VoiceTime\T40.wav”;
else if (min = 50 min 60)
sound = @”VoiceTime\T50.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
min = min % 10;
if (min != 0)
sound = @”VoiceTime\T0″ + min + “.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
sound = @”VoiceTime\MIN.wav”;
sndPlayer = new System.Media.SoundPlayer(sound);
sndPlayer.PlaySync();
if (sndPlayer != null)
sndPlayer.Dispose();
sndPlayer = null;

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

未经允许不得转载:Villain博客 » c#语音报时(含完整的声音资源文件).rar

赞 (0) 打赏

评论 0

评论前必须登录!

登陆 注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏