我正在尝试从 C# 中的 .mp3 文件中检索音频播放器的详细信息。
代码片段:
[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);
}
}
我的问题是:
- 如何设置歌曲的音量?
- 我如何获得歌曲的比特率/采样率?
我更喜欢使用 MCI 或 NAudio,因为我知道它们的可靠性。