mediaplayer 给它一个音乐地址就行了,MSDN里面就有的..
利用DirectX实现声音播放也行,不过我觉得你如果只需一个背景音乐的话..就和不着那么麻烦..
利用DirectX实现声音播放也行,不过我觉得你如果只需一个背景音乐的话..就和不着那么麻烦..
飘过~~
using System.Runtime.InteropServices;
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);
private void button1_Click(object sender, EventArgs e)
{
mciSendString(@"close temp_alias", null, 0, 0);
mciSendString(@"open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias",
null, 0, 0);
mciSendString("play temp_alias", null, 0, 0); // 重复播放用"play temp_alias repeat"
}