Commit ceaf9a32 authored by 潘栩锋's avatar 潘栩锋 🚴

修改bug 报警声 文件没有,会出错

parent c48adad7
......@@ -45,6 +45,7 @@ namespace FLY.ControlLibrary
/// </summary>
public string OKContent { get; set; } = "确定";
public Window_WarningTip()
{
InitializeComponent();
......@@ -74,7 +75,7 @@ namespace FLY.ControlLibrary
/// </summary>
public static void Stop()
{
Current?.timer1_Tick(null,null);
Current?.timer1_Tick(null, null);
}
/// <summary>
/// 关闭
......@@ -90,15 +91,22 @@ namespace FLY.ControlLibrary
{
isRunning = false;
outputDevice?.Stop();
outputDevice.Dispose();
outputDevice?.Dispose();
outputDevice = null;
audioFile.Dispose();
audioFile?.Dispose();
audioFile = null;
}
void playMusic(string musicpath)
{
try
{
audioFile = new AudioFileReader(musicpath);
}
catch
{
//音乐无法启动
return;
}
outputDevice = new WaveOutEvent();
......@@ -116,7 +124,12 @@ namespace FLY.ControlLibrary
}
void Play(string musicpath)
{
if (audioFile == null)
if (musicpath == null)
{
//没有音乐,关闭
stopMusic();
}
else if (audioFile == null)
{
playMusic(musicpath);
}
......@@ -218,7 +231,7 @@ namespace FLY.ControlLibrary
Current.Play(musicpath);
WarningTipID++;
if (WarningTipID >= int.MaxValue-1)
if (WarningTipID >= int.MaxValue - 1)
WarningTipID = 0;
return WarningTipID;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment