C#音效播放PlaySound
生活随笔
收集整理的這篇文章主要介紹了
C#音效播放PlaySound
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
[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#音效播放PlaySound的全部內容,希望文章能夠幫你解決所遇到的問題。