C# 如何用playsound()函数,按顺序播放多个WAV文件
解决方案 »
- 求助,c#编写的播放器..急
- 关于回车\r和换行符\n
- C#求助!
- 帮一把,刚刚开始工作100分拉 那位大哥知道这个问题怎么解决
- 一个转化问题(急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!)
- 进程 或线程的优先权
- 查询分析器可多次执行,但用SqlCommand执行第二次就报错:Mr邹建在吗?请大家帮看一下
- 用.net中自带的Oracle访问组建的blob参数的长度不能超过32k,这问题能解决吗?解决了马上给分
- Visual Studio中,怎麼自動添加namespace的引用。
- 请问如何将ArrayList类型序列化成String?或是其他方法实现?
- 一个简单正则问题
- 在vs.net2008中如何查看SQLSERVER数据库管理系统中启动了哪些数据库,就像SQLSERVER2000的企业管理器那样。现在是在.net中看不到SQLSERVER中到底启动了哪些数据库,哪些数据库“置疑”等
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
public class clsPlaySound
{
protected const int SND_SYNC = 0x0;
protected const int SND_ASYNC = 0x1;
protected const int SND_NODEFAULT = 0x2;
protected const int SND_MEMORY = 0x4;
protected const int SND_LOOP = 0x8;
protected const int SND_NOSTOP = 0x10;
protected const int SND_NOWAIT = 0x2000;
protected const int SND_ALIAS = 0x10000;
protected const int SND_ALIAS_ID = 0x110000;
protected const int SND_FILENAME = 0x20000;
protected const int SND_RESOURCE = 0x40004;
protected const int SND_PURGE = 0x40;
protected const int SND_APPLICATION = 0x80; [DllImport("Winmm.dll", CharSet=CharSet.Auto)]
protected extern static bool PlaySound(string strFile, IntPtr hMod, int flag ); //播放声音函数
//strSoundFile --- 声音文件
//bSynch --- 是否同步,如果为True,则播放声音完毕再执行后面的操作,为False,则播放声音的同时继续执行后面的操作
public static bool PlaySoundFile(string strSoundFile, bool bSynch)
{
if(!System.IO.File.Exists(strSoundFile))
return false;
int Flags;
if(bSynch)
Flags = SND_FILENAME | SND_SYNC;
else
Flags = SND_FILENAME | SND_ASYNC; return PlaySound(strSoundFile, IntPtr.Zero, Flags);
}
}//连续播放时
for each(string file in files)
{
clsPlaySound.PlaySoundFile(file,true);
}
[DllImport("winmm.dll")]
public static extern bool PlaySound(string pszSound,int hmod,int fdwSound);
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001; PlaySound("提示时奏幻想空间.WAV",0,SND_ASYNC|SND_FILENAME);
我菜鸟,
不知道怎么使用你这个函数,谢谢
让我怎么让它播放完这些文件后,又从头播放呢,也就是循环播放
for(i=0;i<files.Lengh;i++)
{
clsPlaySound.PlaySoundFile(files[i],true);
if(i==file.Length)
i==0;
}
为什么只能循环一次,就停止播放了
为什么只能循环一次,就停止播放了
for(i=0;i <files.Lengh;i++)
{
clsPlaySound.PlaySoundFile(files[i],true);
if(i==file.Length - 1)
i==0;
}
现在又有一个问题,如何实现音乐的暂停与播放呢?不好意思又打扰你了,我找了很久好象没有暂停的函数,急!!!谢谢啦!参与有分!!,加分!
然后在OpenNETCF.Media.WaveAudio命名空间下有个Recorder类和Player类,分别控制录音和放音的,有暂停的方法