第一种方法:
/// <summary>
/// 删除/// </summary>
/// <param name="ifTrue"> 是否循环播放是为True否则为False </param>
public static void Delete(Boolean ifTrue)
{
// 声音播放的类
SoundPlayer myplayer = new SoundPlayer();
myplayer.SoundLocation = Application.StartupPath + @" \sound\删除.WAV " ;
if (ifTrue)
{
myplayer.PlayLooping();
}
else
{
myplayer.Play();
}
}
第二种方式:
using System.Threading;
using System.Speech.Synthesis;
// 声音
public void RingVoice()
{
try
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.Speak("请" + mi.Remark3 + "同学," + "在学校门口等候");
}
catch (Exception er)
{
//MessageBox.Show(er.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
调用:
Thread T = new Thread(RingVoice);
T.Start();