您好我正在尝试使用我在此处看到的代码使用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();
提前致谢!