You cannot use controls to prevent playback, or to provide a memory method to store sound data purposes, it is to play sound very accurate, and no sound latency will occur.
[DllImport ( "Winmm.dll")] public static extern long PlaySound (string name, long module, long flag); [DllImport ( "winmm.dll")] private static extern long mciSendString (string lpstrCommand, string lpstrReturnString, long length Long hwndcallback; private string m_musicname = ""; private void playmusic () {m_musicname = "/" " Tool.ReadInfo (" PromptMusicFile " " / "; if (m_musicname.length == 0) return; Try {mcIndstring (@ "close" m_musicname, "", 0, 0); mcIndstring (@ "open" m_musicname, "" ", 0, 0); mcIndstring (@" play " m_musicname," ", 0, 0);} catch {}
}
Private void stopmusic () {Try {mcIndstring (@ "close" m_musicname, "", 0, 0);} catch {}}
WAV files in the player can be like this:
// API Definition Private const INT SND_ASYNC = 0x1; private const INT SND_MEMORY = 0x4;
[DLLIMPORT ("Winmm.dll")] private static extern int SndPlaySounda (byte [] lpszsoundname, int uflags;
// Add BLIP1.WAV to the project and set to embedded resources // now read it into the memory ready-to-use type t = this.gettype (); system.reflection.Assembly a = t.assembly; system.io.Stream Stream = a.getmanifestResourceStream (T.NameSpace ". Blip1.wav"); Byte [] ba = new byte [stream.length]; stream.read (ba, 0, ba.length); stream.close ();
// Play the cache SNDPLAYSOUNDA (Ba, SND_MEMORY);