你的位置:首页 > 软件开发 > ASP.net > C#播放wav文件

C#播放wav文件

发布时间:2016-02-15 11:00:13
C#使用HWQPlayer类播放wav文件类的代码: 1 using System.IO; 2 using System.Runtime.InteropServices; 3 4 namespace HoverTreeSound.HewenqiFrame 5 { 6 inter ...

C#播放wav文件

C#使用HWQPlayer类播放wav文件类的代码:

 1 using System.IO; 2 using System.Runtime.InteropServices; 3  4 namespace HoverTreeSound.HewenqiFrame 5 { 6 internal class HWQPlayer 7 { 8 [DllImport("get='_blank'>winmm.dll")] 9 private static extern int sndPlaySoundA(byte[] lpszSoundName, int uFlags);10 11 private const int SND_MEMORY = 0x4;12 private const int SND_ASYNC = 0x1;13 byte[] StreamToBytes(Stream stream)14 {15 byte[] bytes = new byte[stream.Length];16 stream.Read(bytes, 0, bytes.Length);17 // 设置当前流的位置为流的开始 by 何问起18 stream.Seek(0, SeekOrigin.Begin);19 return bytes;20 }21 22 public void PlayWav(Stream stream)23 {24 sndPlaySoundA(StreamToBytes(stream), SND_MEMORY);25 }26 }27 }
示例下载:http://hovertree.com/h/bjaf/4aaa1b2s.htm界面:

原标题:C#播放wav文件

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录