public partial class Form1 : Form
{
//....
private void button1_Click(object sender, EventArgs e)
{
mp3Play.Play(this,@"sound\铃声1.mp3");
}
public const int MM_MCINOTIFY = 0x3B9;
protected override void DefWndProc(ref Message m)
{
base.DefWndProc(ref m);
//当歌曲播完系统发送MM_MCINOTIFY
if (m.Msg == MM_MCINOTIFY)
{
Console.WriteLine("song end");
}
}
//...
}
class MyMp3Play{
void Play(Form context,string filename){
//省略 ...APIClass.mciSendString("open ...
APIClass.mciSendString("play media notify", null, 0, (int)context.Handle);
}
}