如何不通过硬盘直接播放内存中的音频WAV? sndPlaySound API 函数可以播放内存数据. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void Form1_Load(object sender, System.EventArgs e) { System.IO.FileStream inFile ; Byte[] binaryData; inFile = new System.IO.FileStream(@"C:\test.wav", System.IO.FileMode.Open, System.IO.FileAccess.Read); binaryData=new byte[inFile.Length]; inFile.Read(binaryData, 0, (int)inFile.Length); inFile.Close();//播放内存数据 sndPlaySoundA(binaryData, SND_ASYNC | SND_NODEFAULT | SND_MEMORY); } [System.Runtime.InteropServices.DllImport("WINMM.DLL")] private extern static int sndPlaySoundA(Byte[] lpszSoundName , int uFlags ); const int SND_ASYNC = 0x1; // 异步播放 const int SND_NODEFAULT = 0x2; // 不使用缺省声音 const int SND_MEMORY = 0x4; // lpszSoundName 指向一个内存文件 怎么多线程接收和解析UDP数据 水晶报表汇成xls 请教关于XML的问题 关闭窗口的问题 如何同时检测 “鼠标单击信息和键盘按键信息”? 我有一个关于是C#的问题 如何实现图标拖放的窗体响应 这两个句子有何区别 C调用C#? 一个枚举的问题?(在线等待!!) 网络新手问C#里socket客户端如何接收服务器端不定时发送的数据,采用TCP连接。有什么事件?或委托呢? 散分了。(只限前19 个人)大家抓紧啊。(不可敲回车,写上up即可,否则不给分)
private void Form1_Load(object sender, System.EventArgs e)
{
System.IO.FileStream inFile ;
Byte[] binaryData; inFile = new System.IO.FileStream(@"C:\test.wav",
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
binaryData=new byte[inFile.Length]; inFile.Read(binaryData, 0, (int)inFile.Length);
inFile.Close();
//播放内存数据
sndPlaySoundA(binaryData, SND_ASYNC | SND_NODEFAULT | SND_MEMORY); }
[System.Runtime.InteropServices.DllImport("WINMM.DLL")]
private extern static int sndPlaySoundA(Byte[] lpszSoundName , int uFlags ); const int SND_ASYNC = 0x1; // 异步播放
const int SND_NODEFAULT = 0x2; // 不使用缺省声音
const int SND_MEMORY = 0x4; // lpszSoundName 指向一个内存文件