I am trying to retrieve details from an .mp3 file in C# for an audio player.
Code snip:
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
public static void Close()
{
_command = "close MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = false;
}
public static void Open(string sFileName)
{
_command = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = true;
}
public static void Play(bool loop)
{
if (isOpen)
{
_command = "play MediaFile";
if (loop)
_command += " REPEAT";
mciSendString(_command, null, 0, IntPtr.Zero);
}
}
My questions are:
I would prefer using MCI or NAudio since I am aware of their reliability.
To set volume:
string command = "setaudio MediaFile volume to " + volume.ToString();
error = mciSendString(Pcommand, null, 0, IntPtr.Zero);
where volume is an int between 0 and 1000
There is a whole list of mci command strings on in the multimedia reference on msdn at:
set command
There is also a good example project on CodeProject that does most of the tings you are trying to do at: Simple MCI Player
HTH
Paul