C#中如何播放MP3
答案:2 悬赏:60 手机版
解决时间 2021-11-23 05:14
- 提问者网友:鐵馬踏冰河
- 2021-11-22 07:09
C#中如何播放MP3
最佳答案
- 五星知识达人网友:十年萤火照君眠
- 2021-11-22 07:43
///
/// 使用API
///
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern int mciSendString(string m_strCmd, string m_strReceive, int m_v1, int m_v2);
[DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 GetShortPathName(String path,StringBuilder shortPath, Int32 shortPathLength);
上面是调用API
name = 你的mp3路径
StringBuilder shortpath=new StringBuilder(80);
int result=GetShortPathName(name,shortpath,shortpath.Capacity);
name=shortpath.ToString();
mciSendString(@"close all",null,0,0);
mciSendString(@"open "+name+" alias song",null,0,0); //打开
mciSendString("play song",null,0,0); //播放
/// 使用API
///
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern int mciSendString(string m_strCmd, string m_strReceive, int m_v1, int m_v2);
[DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 GetShortPathName(String path,StringBuilder shortPath, Int32 shortPathLength);
上面是调用API
name = 你的mp3路径
StringBuilder shortpath=new StringBuilder(80);
int result=GetShortPathName(name,shortpath,shortpath.Capacity);
name=shortpath.ToString();
mciSendString(@"close all",null,0,0);
mciSendString(@"open "+name+" alias song",null,0,0); //打开
mciSendString("play song",null,0,0); //播放
全部回答
- 1楼网友:躲不过心动
- 2021-11-22 08:34
[DllImport("winmm.dll")]
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;
PlaySound(@Path+“MP3文件名”+".wav",0,SND_ASYNC|SND_FILENAME);//huang20071006
把文件放在系统的bin下就可以了
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;
PlaySound(@Path+“MP3文件名”+".wav",0,SND_ASYNC|SND_FILENAME);//huang20071006
把文件放在系统的bin下就可以了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯