首页 > 代码库 > 项目--给项目添加提示声音

项目--给项目添加提示声音

1.使用系统内自带的声音

System.Media.SystemSounds.Beep.Play();System.Media.SystemSounds.Asterisk.Play();System.Media.SystemSounds.Exclamation.Play();System.Media.SystemSounds.Hand.Play();System.Media.SystemSounds.Question.Play();

2.使用自定义的声音(非循环播放=== 播放一次;相对路径)

//增加声音提示System.Media.SoundPlayer player = new SoundPlayer();player.SoundLocation = Server.MapPath("~/Admin/voice/system.wav");player.LoadAsync();player.Play();

3.使用自定义声音(循环播放;绝对路径)

//增加声音提示System.Media.SoundPlayer player = new SoundPlayer();player.SoundLocation = @"C:\Program Files\Tencent\QQ\Plugin\com.tencent.paipai\Misc\Sound\PaiPaiMsg.wav";player.LoadAsync();player.PlayLooping(); Thread.Sleep(530);player.Stop();