Any suggestions?
I'm currently trying to use Winmm.dll but for some reason, nothing happens when I go to play my mp3. I can't really embed WMP, so I'm not sure what else to do.
-
-
What you're trying to do definitely works. I tried it by implementing the MCI in the simplest form that I could and now have music playing from a blank console window.
Put this into a new class called 'File' and remember to reference the System.Runtime.InteropServices namespace:[DllImport("winmm.dll")]
static extern int mciSendString(string mciCommand, StringBuilder buffer, int bufferSize, IntPtr callback); string fileName;
public void Send(string mciCommand) { mciSendString(mciCommand, null, 0, IntPtr.Zero); }
public File(string fileLocation)
{
fileName = fileLocation;
Send("open " + fileName);
}
public void Play() { Send("play " + fileName); }
Then drop this into your startup object:File file = new File("C:/Test.mp3"); file.Play(); string input = Console.ReadLine();
It should work now. At the moment it won't do anything other than play the file but the MSDN section on MCI describes all the additional commands that can be called. -
Hmm, I finally got around to trying your code example. It seems that when I decide to use an alias "open fileName alias MySound" it doesn't work. Without the alias and just a simple "open fileName" it works fine.tfraser said:What you're trying to do definitely works. I tried it by implementing the MCI in the simplest form that I could and now have music playing from a blank console window.
Put this into a new class called 'File' and remember to reference the System.Runtime.InteropServices namespace:[DllImport("winmm.dll")]
static extern int mciSendString(string mciCommand, StringBuilder buffer, int bufferSize, IntPtr callback); string fileName;
public void Send(string mciCommand) { mciSendString(mciCommand, null, 0, IntPtr.Zero); }
public File(string fileLocation)
{
fileName = fileLocation;
Send("open " + fileName);
}
public void Play() { Send("play " + fileName); }
Then drop this into your startup object:File file = new File("C:/Test.mp3"); file.Play(); string input = Console.ReadLine();
It should work now. At the moment it won't do anything other than play the file but the MSDN section on MCI describes all the additional commands that can be called.
Strange.
Anyway, thanks for the sample!
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.