使用mciSendString使用BackgroundWorker播放MP3

时间:2013-05-01 05:22:23

标签: c# backgroundworker mcisendstring

您好我正在尝试使用我在此处看到的代码使用BackgroungWorker播放MP3文件。

我的播放功能在没有背景工作者的情况下工作得很好,为什么我不能这样玩呢?

        BackgroundWorker bw = new BackgroundWorker();


        bw.WorkerReportsProgress = true;


        bw.DoWork += new DoWorkEventHandler(
        delegate(object o, DoWorkEventArgs args)
        {
            BackgroundWorker b = o as BackgroundWorker;

            string path = System.IO.Path.GetFullPath(".../.../sounds/") + "C4" + ".mp3";
            string command;
            command = "open \"" + path + "\" type mpegvideo alias fileC4";
            mciSendString(command, null, 0, IntPtr.Zero);
            command = "play all";
            mciSendString(command, null, 0, IntPtr.Zero);
        });


        bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
        delegate(object o, RunWorkerCompletedEventArgs args)
        {
            label1.Text = "HOORAY!";
        });

        bw.RunWorkerAsync();

提前致谢!

0 个答案:

没有答案