C#音效播放PlaySound



[DllImport("winmm.dll", EntryPoint = "PlaySound")]
private static extern bool PlaySound(string pszSound, IntPtr hmod, uint fdwSound);
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;

//用API播放声音文件, 异步,覆盖播放(1,不会堵塞UI  2,播放第二个音效的时候,第一个音效自动停止)
void ReadSound(string WavFilePath)
{
	PlaySound(WavFilePath, IntPtr.Zero, SND_FILENAME | SND_ASYNC);      
}

你可能感兴趣的:(C#)