在C#里,如何用API播放MIDI乐音,这里的代码看不动,谁来个详细的例子。
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Music
{
/**//// <summary>
///
/// </summary>
public class Audio
{
[DllImport("winmm.dll")]
private static extern int mciSendString
(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName
(
[MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int shortPathLength
);
public Audio()
{
}
public void Play(string FileName)
{
StringBuilder shortPathTemp = new StringBuilder(255);
int result = GetShortPathName(FileName, shortPathTemp, shortPathTemp.Capacity);
string ShortPath = shortPathTemp.ToString();
mciSendString("open "+ShortPath+" alias song","",0,0);
mciSendString("play song","",0,0);
}
public void Stop()
{
mciSendString("stop song","",0,0);
}
public void Pause()
{
mciSendString("pause song","",0,0);
}
public void Close()
{
mciSendString("close song","",0,0);
}
}
}
在C#里,如何用API播放MIDI乐音,这里的代码看不动,谁来个详细的例子。
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Music
{
/**//// <summary>
///
/// </summary>
public class Audio
{
[DllImport("winmm.dll")]
private static extern int mciSendString
(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName
(
[MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int shortPathLength
);
public Audio()
{
}
public void Play(string FileName)
{
StringBuilder shortPathTemp = new StringBuilder(255);
int result = GetShortPathName(FileName, shortPathTemp, shortPathTemp.Capacity);
string ShortPath = shortPathTemp.ToString();
mciSendString("open "+ShortPath+" alias song","",0,0);
mciSendString("play song","",0,0);
}
public void Stop()
{
mciSendString("stop song","",0,0);
}
public void Pause()
{
mciSendString("pause song","",0,0);
}
public void Close()
{
mciSendString("close song","",0,0);
}
}
}
在C#里,如何用API播放MIDI乐音,这里的代码看不动,谁来个详细的例子。
解决方案 »
- 在线等:OLEDB远程连接SQL Server服务器的问题
- 求一个正则表达式
- 程序实现注册dll的问题,同时给用户反馈信息
- 如何使窗体的最大化按钮变灰失效?
- 想把4张 长20000px 宽20000px 的图片合成为一张大图该怎么做啊,好像photoshop最大只能生成30000px的图像?
- 只有xml,反序列化时new XmlSerializer(typeof(类名)) 类名问题
- 做一个mp3分割软件
- 如何让 Form 中的 控件一起显示,而不是一个一个显示?
- listbox 问题,急啊!!不知道的也帮忙顶顶啊!
- 如何禁掉IE中的后退功能!
- 多线程委托的问题,各位请进,在线等!
- 新人写的代码,来批批
今天正好翻到 lz去找找