Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Play MP3 with BackgroundWorker using mciSendString

$
0
0

Hello I am trying to play an MP3 file with BackgroungWorker.

My playing function is working just fine without the backgroundworker, so why I can't play it like this?

BackgroundWorker bw =newBackgroundWorker();


        bw.WorkerReportsProgress=true;


        bw.DoWork+=newDoWorkEventHandler(delegate(object o,DoWorkEventArgs args){BackgroundWorker b = o asBackgroundWorker;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+=newRunWorkerCompletedEventHandler(delegate(object o,RunWorkerCompletedEventArgs args){
            label1.Text="HOORAY!";});

        bw.RunWorkerAsync();


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>