Med*_*000 4 c# audio mp3 winmm
MCIERR_INTERNALI我正在尝试在应用程序中制作一个简单的媒体播放器,但我注意到我的代码不会播放音乐,除非该文件的比特率低于192kbps或更低.问题是我的大部分音乐都在260-320kbps左右.
这是我的代码,如果有什么我可以做的'可用'比特率选项让我知道,否则我需要一个新的DLL建议!
class MusicPlayer
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);
private static void checkMCIResult(long code)
{
int err = (int)(code & 0xffffffff);
if (err != 0)
{
throw new Exception(string.Format("MCI error {0}", err));
}
}
public void open(string file)
{
string command = "open \"" + file + "\" type MPEGVideo alias MyMp3";
checkMCIResult(mciSendString(command, null, 0, 0));
}
public void play()
{
string command = "play MyMp3";
mciSendString(command, null, 0, 0);
}
public void pause()
{
string command = "stop MyMp3";
mciSendString(command, null, 0, 0);
}
}
Run Code Online (Sandbox Code Playgroud)
**编辑: - 申请表格
- 使用Windows 7 sp1
- 使用Visulal Studio 2013社区版
- 从错误捕获我现在看到错误号是289,-256 = 22:MCIERR_INTERNAL,不知道这是什么关于
这不是Windows中的固有限制,这些问题是环境问题.基本检查清单:
错误检查器方法的简单实现:
private static void checkMCIResult(long code) {
int err = (int)(code & 0xffffffff);
if (err != 0) {
throw new Exception(string.Format("MCI error {0}", err));
}
}
Run Code Online (Sandbox Code Playgroud)
用法:
public static void open(string file) {
string command = "open \"" + file + "\" type MPEGVideo alias MyMp3";
checkMCIResult(mciSendString(command, null, 0, 0));
}
Run Code Online (Sandbox Code Playgroud)
有很多可能的MCI错误,你会发现它们列在你机器上Windows SDK"include"目录的MMSystem.h文件中.像C:\ Program Files(x86)\ Microsoft SDKs\Windows\v7.1A\Include\MMSystem.h.从MCIERR_INVALID_DEVICE_ID开始,从错误代码中减去256.总是提到您的Windows和VS版本顺便说一句.
| 归档时间: |
|
| 查看次数: |
1122 次 |
| 最近记录: |