Paip. Solution to sound latency
Author Attilax, EMAIL: 1466519819@qq.com
A Selection box for opening a file has a button sound... but the button sound delay is very high. It will only sound when the box comes out, more than a second ..
The method of releasing the code to throw the thread does not solve the problem.
Sleep between playing and opening OpenFileDialog. Thread. SLEEP (200); basically OK, but it will slow down the speed of opening the file box. It will be ineffective to reduce Sleep ..
It seems that we have to call WIN32 API to solve the problem.
... Read the file into the memory... When FORM_LOAD... the principle is to call winmm. dll, and then play it when the button is clicked... the effect is OK ..
---------- Code
Reference MOLEI. dll
SoundClickC417 scC4h = new SoundClickC417 ("");
ScC4h. playByte ();
------ The original code in the framework is as follows:
[DllImport ("winmm. dll")]
Private static extern int sndPlaySoundA (byte [] lpszSoundName, int uFlags );
// Play Cache
SndPlaySoundA (ba, SND_MEMORY );