private SoundPlayer AlarmBell = null;
public void AlarmBellPlay()
{
if (null != AlarmBell)
{
AlarmBell.Stop();
AlarmBell.Dispose();
}
AlarmBell = new SoundPlayer
{
SoundLocation = AppCfg.Instance.AlarmVoicePath
};
try
{
AlarmBell.LoadAsync(); //设置播放的方法(同步,异步)
AlarmBell.PlayLooping(); //播放声音文件 (单一,循环)
}
catch (Exception)
{
SystemSounds.Hand.Play();
AlarmBell.Dispose();
}
}
通过SoundPlayer 播放.wav 格式的音频
最新推荐文章于 2024-03-20 14:08:44 发布