You cannot use controls to prevent playback delays or provide a memory method to store sound data. The purpose is to play the sound accurately without the sound delay. From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx [Dllimport ("winmm. dll")]
You cannot use controls to prevent playback delays or provide a memory method to store sound data. The purpose is to play the sound accurately without the sound delay. From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx [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 { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); Mcisendstring (@ "open" + m_musicname, "", 0, 0 ); Mcisendstring (@ "play" + m_musicname, "", 0, 0 ); } Catch { } } Private void stopmusic () { Try { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); } Catch {} } You can play the wav files in the memory as follows: // 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 it as an embedded Resource // Read it into the memory for backup 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 Cache Sndplaysounda (BA, snd_memory ); Note: Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it. Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource. Assembly assem = assembly. getexecutingassembly (); Stream stream = assem. getmanifestresourcestream ( "Ums. datadefinition." + strobjname + ". xml "); For more information, see explain. |
You cannot use controls to prevent playback delays or provide a memory method to store sound data. The purpose is to play the sound accurately without the sound delay. From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx [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 { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); Mcisendstring (@ "open" + m_musicname, "", 0, 0 ); Mcisendstring (@ "play" + m_musicname, "", 0, 0 ); } Catch { } } Private void stopmusic () { Try { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); } Catch {} } You can play the wav files in the memory as follows: // 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 it as an embedded Resource // Read it into the memory for backup 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 Cache Sndplaysounda (BA, snd_memory ); Note: Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it. Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource. Assembly assem = assembly. getexecutingassembly (); Stream stream = assem. getmanifestresourcestream ( "Ums. datadefinition." + strobjname + ". xml "); For more information, see explain. |
You cannot use controls to prevent playback delays or provide a memory method to store sound data. The purpose is to play the sound accurately without the sound delay. From http://blog.csdn.net/jery_lee/archive/2004/08/06/67239.aspx [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 { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); Mcisendstring (@ "open" + m_musicname, "", 0, 0 ); Mcisendstring (@ "play" + m_musicname, "", 0, 0 ); } Catch { } } Private void stopmusic () { Try { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); } Catch {} } You can play the wav files in the memory as follows: // 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 it as an embedded Resource // Read it into the memory for backup 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 Cache Sndplaysounda (BA, snd_memory ); Note: Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it. Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource. Assembly assem = assembly. getexecutingassembly (); Stream stream = assem. getmanifestresourcestream ( "Ums. datadefinition." + strobjname + ". xml "); There are also some ways to refer to the http://hi.baidu.com/%D3%DE%D6%D0%D7%F7%C0%D6/blog/item/0a621344de1aec85b2b7dc92.html 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 { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); Mcisendstring (@ "open" + m_musicname, "", 0, 0 ); Mcisendstring (@ "play" + m_musicname, "", 0, 0 ); } Catch { } } Private void stopmusic () { Try { Mcisendstring (@ "close" + m_musicname, "", 0, 0 ); } Catch {} } You can play the wav files in the memory as follows: // 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 it as an embedded Resource // Read it into the memory for backup 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 Cache Sndplaysounda (BA, snd_memory ); Note: Resources obtained using getmanifestresourcestream must be included in the project and not included in the project, even in the same directory. After the file is included in the project, change "generate operation" in the "attribute" of the file to "embedded resource ". You can use it. Use getmanifestresourcenames (like this name) to retrieve all the names and then see if you want them. It is generally Assembly name. Class Name. manifest. Resource. Assembly assem = assembly. getexecutingassembly (); Stream stream = assem. getmanifestresourcestream ( "Ums. datadefinition." + strobjname + ". xml "); For more information, see explain. |