我引用了Windows Media Player组件了工具栏里没有出现Media Player啊???

解决方案 »

  1.   

    如果你想播放MP3,我推荐下面的代码,很好用的.http://bingning.net[System.Runtime.InteropServices.DllImport("winmm.dll")]
    private static extern int mciSendString(String command,
       StringBuilder buffer, int bufferSize, IntPtr hwndCallback);private string aliasName = "MediaFile";private void Button1_Click(object sender, EventArgs e)
    {
        string fileName = "C:\\music.mp3";    string cmd;
        cmd = "open \"" + fileName + "\" type mpegvideo alias " + aliasName;
        if (mciSendString(cmd, null, 0, IntPtr.Zero) != 0)
            return;
        cmd = "play " + aliasName;
        mciSendString(cmd, null, 0, IntPtr.Zero);
    }private void Button2_Click(object sender, EventArgs e)
    {
        string cmd;
        cmd = "stop " + aliasName;
        mciSendString(cmd, null, 0, IntPtr.Zero);
        cmd = "close " + aliasName;
        mciSendString(cmd, null, 0, IntPtr.Zero);
    }