C# 如何用playsound()函数,按顺序播放多个WAV文件

xiaosu123 2008-09-28 11:30:01
C# 如何用playsound()函数,按顺序播放多个WAV文件
...全文
2416 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
gxingmin 2008-10-05
  • 打赏
  • 举报
回复
晕,最近我正在PocketPC上做一个录音/播放程序,不过我用的Mobile5.0,不是WinCE

你可以引用OpenNETCF类库
然后在OpenNETCF.Media.WaveAudio命名空间下有个Recorder类和Player类,分别控制录音和放音的,有暂停的方法
xiaosu123 2008-10-05
  • 打赏
  • 举报
回复
啊,我用的是Compact Framework 2.0,是没有的
xiaosu123 2008-10-05
  • 打赏
  • 举报
回复
我试一下看看
zbking 2008-10-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gxingmin 的回复:]
C# code
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 con…
[/Quote]

mark jf
lextm 2008-10-04
  • 打赏
  • 举报
回复
Compact Framework 3.5带有SoundPlayer的。
xiaosu123 2008-10-04
  • 打赏
  • 举报
回复
我是在WINCE下编程的,WINCE下C#是没有这个”System.Media“的
gxingmin 2008-10-04
  • 打赏
  • 举报
回复
System.Media下有个SoundPlayer类,你试一试这个看看
xiaosu123 2008-10-03
  • 打赏
  • 举报
回复
但是,用suppend的话,它不能立即停止当前播放的音乐,只有等到播放完一首音乐后,才暂停,而且在WINCE下是没有suppend
Luckyboys 2008-10-03
  • 打赏
  • 举报
回复
用线程的话,应该可以suppend了线程的吧
xiaosu123 2008-10-03
  • 打赏
  • 举报
回复
to gxingmin :
现在又有一个问题,如何实现音乐的暂停与播放呢?不好意思又打扰你了,我找了很久好象没有暂停的函数,急!!!谢谢啦!参与有分!!,加分!
xiaosu123 2008-09-28
  • 打赏
  • 举报
回复
to gxingmin :
让我怎么让它播放完这些文件后,又从头播放呢,也就是循环播放
leecopper 2008-09-28
  • 打赏
  • 举报
回复
帮顶
LoveYouT 2008-09-28
  • 打赏
  • 举报
回复
可以查看帮助,选中函数按F1
xiaosu123 2008-09-28
  • 打赏
  • 举报
回复
to gxingmin :
我菜鸟,
不知道怎么使用你这个函数,谢谢
JeffChung 2008-09-28
  • 打赏
  • 举报
回复

[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);

gxingmin 2008-09-28
  • 打赏
  • 举报
回复

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);
}
zhaogy 2008-09-28
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 gxingmin 的回复:]
//连续播放时,播完从头播
for(i=0;i <files.Lengh;i++)
{
clsPlaySound.PlaySoundFile(files[i],true);
if(i==file.Length)
i==0;
}
[/Quote]


//连续播放时,播完从头播
for(i=0;i <files.Lengh;i++)
{
clsPlaySound.PlaySoundFile(files[i],true);
if(i==file.Length - 1)
i==0;
}
xiaosu123 2008-09-28
  • 打赏
  • 举报
回复
to gxingmin :
为什么只能循环一次,就停止播放了
xiaosu123 2008-09-28
  • 打赏
  • 举报
回复
to gxingmin :
为什么只能循环一次,就停止播放了
加载更多回复(4)

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧