永发信息网

c#播放声音最好的方法

答案:3  悬赏:0  手机版
解决时间 2021-04-01 13:52
  • 提问者网友:像風在裏
  • 2021-04-01 06:43
c#播放声音最好的方法
最佳答案
  • 五星知识达人网友:舍身薄凉客
  • 2021-04-01 07:44
添加命名空间引用:

using System.Runtime.InteropServices;

然后声明:

[DllImport("winmm.dll")]
public static extern bool PlaySound(String Filename, int Mod, int Flags);

播放:

PlaySound(@"e:\Music\login.wav", 0, 1); //把1替换成9,可连续播放

或者

PlaySound(System.Windows.Forms.Application.StartupPath+@"\Music\login.wav", 0, 1);

PlaySound(@"..\..\Music\login.wav", 0, 1);
全部回答
  • 1楼网友:舍身薄凉客
  • 2021-04-01 08:14
播放声音?
如果只要求用WAV的画 楼上几位都是正解
如果要求还有别的
那可以调用COM组建 用media控件
  • 2楼网友:持酒劝斜阳
  • 2021-04-01 07:51
[DllImport("winmm.dll")]
private static extern long sndPlaySound(string lpszSoundName,long uFlags);
public static void PlaySound(string fileName)
{
sndPlaySound(fileName,1);
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯