标签:
本文是转载的文章。原文出处:http://blog.csdn.net/jijunwu/article/details/4753094
声音文件folder.wav放置在bin目录下debug下
using System.Runtime.InteropServices;
[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("folder.wav", 0, SND_ASYNC | SND_FILENAME);
using System.Media;
SoundPlayer p = new SoundPlayer();
p.SoundLocation = Application.StartupPath + "//folder.wav";
p.Load();
p.Play();
支持同步、异步播放
支持循环播放
支持文件和流播放
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = Application.StartupPath + "//folder.wav";
player.Load();
player.Play();
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = Application.StartupPath + "//folder.wav";
player.LoadAsync();
player.PlaySync();
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = Application.StartupPath + "//folder.wav";
player.Load();
player.PlayLooping();
using Microsoft.VisualBasic.Devices;//Microsoft.VisualBasic.dll需要添加引用
Audio a = new Audio();
a.Play("folder.wav");
标签:
原文地址:http://www.cnblogs.com/woaic/p/5523747.html