瀏覽代碼

修改提示音延迟

章政 8 年之前
父節點
當前提交
9c5d0be1c3
共有 1 個文件被更改,包括 10 次插入11 次删除
  1. 10 11
      UAS-MES/CustomControl/RichText/RichTextAutoBottom.cs

+ 10 - 11
UAS-MES/CustomControl/RichText/RichTextAutoBottom.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Drawing;
+using System.Media;
 using System.Threading;
 using System.Windows.Forms;
 using UAS_MES.PublicMethod;
@@ -37,14 +38,13 @@ namespace UAS_MES.CustomControl.RichText
             {
                 FileName = Application.StartupPath + @"\Resources\Sound\5185.wav";
                 thread.Start();
-                thread = new Thread(PlaySound);
+
             }
-            else if(color == Color.Green && Entity.SystemInf.CheckAudioEnable)
+            else if (color == Color.Green && Entity.SystemInf.CheckAudioEnable)
             {
                 //颜色是绿色,进行正确提示音
                 FileName = Application.StartupPath + @"\Resources\Sound\8378.wav";
                 thread.Start();
-                thread = new Thread(PlaySound);
             }
         }
 
@@ -66,7 +66,7 @@ namespace UAS_MES.CustomControl.RichText
                 thread.Start();
                 thread = new Thread(PlaySound);
             }
-            else if(color == Color.Green && Entity.SystemInf.CheckAudioEnable)
+            else if (color == Color.Green && Entity.SystemInf.CheckAudioEnable)
             {
                 //颜色是绿色,进行正确提示音
                 FileName = Application.StartupPath + @"\Resources\Sound\8378.wav";
@@ -84,15 +84,14 @@ namespace UAS_MES.CustomControl.RichText
             }
             try
             {
-                SpeechLib.SpVoiceClass pp = new SpeechLib.SpVoiceClass();
-                SpeechLib.SpFileStreamClass spFs = new SpeechLib.SpFileStreamClass();
-                spFs.Open(FileName, SpeechLib.SpeechStreamFileMode.SSFMOpenForRead, true);
-                SpeechLib.ISpeechBaseStream Istream = spFs as SpeechLib.ISpeechBaseStream;
-                pp.SpeakStream(Istream, SpeechLib.SpeechVoiceSpeakFlags.SVSFIsFilename);
-                spFs.Close();
+                SoundPlayer player = new SoundPlayer();
+                player.SoundLocation = FileName;
+                player.Load();
+                player.Play();
             }
-            catch (Exception)
+            catch (Exception e)
             {
+                MessageBox.Show(e.Message);
                 Entity.SystemInf.CheckAudioEnable = false;
             }
         }