我在网站上找到了这个类(class):
class MP3Handler
{
private string _command;
private bool isOpen;
[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);
public void Close()
{
_command = "close MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = false;
}
public void Open(string sFileName)
{
_command = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = true;
}
public void Play(bool loop)
{
if (isOpen)
{
_command = "play MediaFile";
if (loop)
_command += " REPEAT";
mciSendString(_command, null, 0, IntPtr.Zero);
}
}
}
有停止和播放的方法。我想知道是否有人熟悉 winmm.dll 库。如何在歌曲播放时暂停它,然后从暂停的地方继续播放?
最佳答案
This CodeProject 文章包含一个处理 winmm.dll 库的许多功能的类,包括暂停,并且可能对此和将来有所帮助。
然而,基本代码是:
_command = "pause MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
关于c# - 如何使用 C# 暂停 MP3 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1704729/