C# MP3 Player using winmm.dll

醉酒当歌 提交于 2019-12-07 05:45:29
Firoz

You can get notification from mcisendstring command when you calling mcisendstring for opening the file just send the handle of your form and override the wndproc method of your form then u can get the notify from MCI sample code as follow.`

 private void btnplay_Click(object sender, EventArgs e)
{
    if (ofd.FileName == "")
    {
        if (ofd.ShowDialog() == DialogResult.OK)
        {
            ofd.Filter = "MP3 Files|*.mp3";
            CommandString = "open " + "\"" + ofd.FileName + "\"" + " type MPEGVideo alias Mp3File";
            mciSendString(CommandString, null, 0, this.Handle.ToInt64());
            CommandString = "play Mp3File";
            mciSendString(CommandString, null, 0, this.Handle.ToInt64());
        }
    }

    else
    {
        CommandString = "play Mp3File";
        mciSendString(CommandString, null, 0, this.Handle.ToInt64());
    }
}

// Declare the nofify constant
public const int MM_MCINOTIFY = 953;

// Override the WndProc function in the form
protected override void WndProc(ref Message m) 
{

    if (m.Msg == MM_MCINOTIFY)
    {
        // The file is done playing, do whatever
    }
    base.WndProc(ref m);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!