C#怎么添加音乐

来源:百度知道 编辑:UC知道 时间:2024/07/04 10:53:39
最近想做一个闹钟程序..
不过不知道怎么添加声音..
只能用弹出的对话框代替
请各位高手解答一下怎么添加声音
越详细越好

我说的是Winforms下播放音乐,这种方法只能播放wav格式的文件。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace music
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
SoundPlayer s = new SoundPlayer(@"D:\sound.wav");
s.Play();
}
}
}

[DllImport("winmm.dll")]
private static extern bool PlaySound(string pszSound, int hmod, int fdwSound);
private const int SND_FILENAME = 0x00020000;
private const int SND_ASYNC = 0x0001;

/// <summary>
/// 播放声音
/// </summary>
/// <param name=